客户要求把一个程序A(从别处购买),嵌入到要开发的程序中。我们的程序运行时,能在同在一个界面,查看另一个程序中的面面,对另外一程序进行操作。
如果有办法另开帖给分。

解决方案 »

  1.   

    很早以前曾做过一个东东,是把两个程序(EXE)的界面合并,我是截断了程序中的Create做的,不过这两个程序都是很简单的程序,按照你的说法,这些商业软件不适合吧,很麻烦并且稳定性无法保证。
      

  2.   

    syy64(太平洋) 
    能否详细说一下。那个程序只是个exe程序,不是com的。
      

  3.   

    要不然用Winexe和
    GLuint WINAPI ProcessSelection(CMyDoc* m_pDoc, GLuint hits, GLuint buffer[], bool bCutTree)
    {
    unsigned int i;
    CString str, strCommand, strDisplay;
    GLuint names, *ptr, id, idd;
    int z1, z2, zmin;
    RECT ChildRect;

    ChildRect.left = 100;
    ChildRect.right = 400;
    ChildRect.top = 100;
    ChildRect.bottom = 300;
    zmin = -1;
    ptr = (GLuint*)buffer;
    for(i=0;i<hits;i++)
    {
    names = *ptr;
    ptr++;
    z1 = *ptr;
    ptr++;
    z2 = *ptr;
    ptr++;
    id = *ptr;
    ptr++;
    if(id==0)continue;
    if(zmin==-1)
    {
    zmin = z2;
    idd = id;
    }
    else if(z2<zmin)
    {
    zmin = z2;
    idd = id;
    }
    }
    if(bCutTree)return idd;
    if(idd<10)
    str.Format("0%u", idd);
    else
    str.Format("%u", idd);

    CString strPath;
    LPTSTR pszPath;
    CString strCommandLine;
    LPTSTR pszCommandLine;
      
    STARTUPINFO startup;
    PROCESS_INFORMATION process;
    BOOL tSuccess;   
       
    strPath += _T( "hpvfp6vr.exe" );   
    memset( &startup, 0, sizeof( startup ) );
    startup.cb = sizeof( startup );
    startup.dwFlags = STARTF_USESHOWWINDOW|STARTF_USEPOSITION;
    startup.wShowWindow = SW_HIDE;
    startup.dwX = 400;
    startup.dwY = 100;
    memset( &process, 0, sizeof( process ) ); strCommandLine.Format( "\"%s\" %s %s", LPCTSTR( strPath ), "2", str);
    pszCommandLine = strCommandLine.GetBuffer( 0 );
    tSuccess = CreateProcess( NULL, pszCommandLine, NULL, NULL, false,
    0, NULL, NULL, &startup, &process );
    strCommandLine.ReleaseBuffer();
    if( tSuccess )
    {
    // Close the handles that CreateProcess returned so we don't leak
    // kernel resources.
    ASSERT( process.hProcess != NULL );
    CloseHandle( process.hProcess );
    ASSERT( process.hThread != NULL );
    CloseHandle( process.hThread );
    }
    else
    {
    strDisplay = "hpvfp6vr.exe 运行文件没有发现,请检查路径是否正确,文件名是否有效!";
    ::MessageBox(NULL, strDisplay, "错误:", MB_OK|MB_ICONQUESTION|MB_SETFOREGROUND);
    }/* strCommand.Format("hpvfp6vr %s %s", "2", str);
    if(::WinExec(strCommand, SW_HIDE)<=31)
    {
    strDisplay = "hpvfp6vr.exe 运行文件没有发现,请检查路径是否正确,文件名是否有效!";
    ::MessageBox(NULL, strDisplay, "错误:", MB_OK|MB_ICONQUESTION|MB_SETFOREGROUND);
    } */
    return idd;
      

  4.   

    to: syy64(太平洋) 
    您提供的方法,运行稳定性如何?
      

  5.   

    用CreateProcess可以,去msdn查吧,不过是有点麻烦的.
    还有几个类似的叫winexe什么来着,简单一些,不过msdn不推荐使用.
    最好是ole了
      

  6.   

    你可以把要被迁入的exe设父窗口。
    你在你的程序里面用一个findwindows()找到窗口句柄,然后setparent(),将这个窗口的父窗口设置为你的exe的窗口。不过要注意界面位置,否则不美观