用rundll32.exe调用 mydll 可是在关机时无法结束dll
用rundll32.exe调用 mydll 可是在关机时无法结束dll。。。我的程序如下:
#include <vcl.h>
#include <windows.h>
#include "Unit1.h"
#pragma hdrstop
#pragma argsused
extern "C"
{
__declspec(dllexport) __stdcall bool abc();
}
//------------------------------------------------------------------------int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//------------------------------------------------------------------------
__declspec(dllexport) __stdcall bool abc()
{
//
MSG msg;
if(FindWindow("TForm1",Form1->Caption.c_str()))
return 1;
try
{
Application->Initialize();
Application->ShowMainForm=false;
ShowWindow(Application->Handle,SW_HIDE);
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
/*if (PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}*/
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
ShowMessage(msg.lParam);
switch(msg.wParam)
{
case WM_QUERYENDSESSION:
break;
case WM_ENDSESSION:
break;
default:
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return false;
}
}
为什么我的DLL不能结束。。