X
xf_z
Unregistered / Unconfirmed
GUEST, unregistred user!
我用下面的代码可以正常的执行,只是卸载DLL的时候出错,应该怎么做啊? procedure ThreadProc(p : pointer); stdcall; begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end; procedure DllMain(dwReason : DWORD); var dwThreadID : DWORD; begin case dwReason of DLL_PROCESS_ATTACH : begin hThreadHandle := CreateThread(nil, 0, @ThreadProc, nil, 0, dwThreadID); end; DLL_PROCESS_DETACH : begin if (hThreadHandle <> 0) then begin form1.Close; //这样卸载不行啊,form1.free也不行 TerminateThread(hThreadHandle, 0); end; end; DLL_THREAD_ATTACH : begin end; DLL_THREAD_DETACH : begin end; end; end;