lzq123335 发表于 2006-9-8 17:57:12

网上看的一个提问帖子关于动态库调用的

Now, I want to load a dll in WR,and I meet some problems.
step1: Create a dll in VC++,I want to kill a process which the dll is informed by the process's classname and its title
//////////KillProcess.cpp/////////////////////
_declspec(dllexport) int KillProcess(char* strClassName,char* strAppTitle)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HWND hwnd;
hwnd=FindWindow(strClassName,strAppTitle);
if(hwnd!=NULL)
{
SendMessage(hwnd,WM_CLOSE,0,0);
return 0;
}
else
{
AfxMessageBox("Already closed!",MB_OK,-1);
return 1;
}

}

step2: Declare the function in the KillProcess.h
/////// I have added a statement
_declspec(dllexport) int KillProcess(char*,char*)

step3: Compile and build it.

step3: Copy the KillProcess.dll to the path D:\MyDll

step4:In the WinRunner,I did it as follows:
unload_dll("");
extern int KillProcess(string,string);
load_dll("D:\\MyDll\\KillProcess.dll");
KillProcess("Notepad","124.txt - Notepad"); ##An error occured, saying "function KilProcess RCP ERROR"
unload_dll("");


Please tell me why?Thanks

生如火花 发表于 2006-9-11 09:41:47

load_dll()

lzq123335 发表于 2006-9-11 09:49:42

是啊,这就是加载动态库问题啊。很奇怪啊
页: [1]
查看完整版本: 网上看的一个提问帖子关于动态库调用的