|
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow )
{
// TODO: Place code here.
HWND hwnd;
if (hwnd = FindWindow(NULL, L"eCMSNK"))
{
SetFocus(hwnd);
return (TRUE);
}
g_hInstance = hInstance; //Save instance handle in global
InitCommonControls();
HINSTANCE hInstance = LoadLibrary( _T("\\USER\\ECMS\\RUN\\eCMSAlarmServer.dll") );
if ( hInstance==NULL )
return FALSE;
hwnd = CreateDialog( g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_ECMSNK), NULL, MainDlgProc );
if ( hwnd==NULL )
return 1;
while ( !g_bStop )
{
Sleep(100);
}
return 0;
}
贴出代码如上所示,LoadLibrary返回NULL,但是这个DLL和exe存放在同一个目录下。
我如果在evc工程的Project->Setting中将这个DLL的.LIB文件加进来,就可以正常LoadLibrary了。
很奇怪,因为正常情况下,LoadLibrary是不需要.LIB文件的,为什么这里需要引用了.LIB文件才能正常LoadLibrary? |
|