标题: 网上看的一个提问帖子关于动态库调用的 [打印本页] 作者: lzq123335 时间: 2006-9-8 17:57 标题: 网上看的一个提问帖子关于动态库调用的 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("");