我有两个.exe
s。他们需要在运行时使用彼此的功能。一种是基于对话的应用程序.exe
,另一种是主要应用程序.exe
。现在主应用程序需要使用基于对话框的应用程序功能。但是在编译时,它可能会 bot 能够定位 的存在,called function
因为dialog based applications .lib
. 因为如果我制作基于对话框的应用程序.lib
,那么程序将在运行时失败。所以,我需要打电话.exe
给另一个.exe
。当我尝试打电话时,
TestClass tc;/* Call dialog based application exe functions*/
tc.MyTest();
它抛出错误,如
1>CallExe.obj : error LNK2001: unresolved external symbol "public: __thiscall TestClass::~TestClass(void)" (??1TestClass@@QAE@XZ)
1>CallExe.obj : error LNK2001: unresolved external symbol "public: void __thiscall TestClass::MyTest(void)" (?MyTest@TestClass@@QAEXXZ)
1>CallExe.obj : error LNK2001: unresolved external symbol "public: __thiscall TestClass::TestClass(void)" (??0TestClass@@QAE@XZ)
Main application.cpp
int _tmain(int argc, _TCHAR* argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
TestClass tc;/* Call dialog based application exe functions*/
tc.MyTest();
// set the size of the structures
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LPCTSTR szCmdline = (LPCTSTR)(TEXT("Dialog.exe"));
// start the program up
if(!CreateProcess(TEXT("D:\\Rasmi's\\Personal\\Visual Studio\\Dialog\\Debug\\Dialog.exe"), // the path
argv[1], // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{cout << "Unable to create\n";}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
在Dialog.exe
TestClass::TestClass(void)
{
}
TestClass::~TestClass(void)
{
}
void TestClass::MyTest()
{
cout << "This is my Test Class \n";
}