Article View: borland.public.cppbuilder.nativeapi
Article #7822Re: Close Form in DLL
From: KL Chin
Date: Tue, 21 Dec 2004 11:44
Date: Tue, 21 Dec 2004 11:44
111 lines
5006 bytes
5006 bytes
Hi Remy, Sorry, for the un-clear code, as mentioned the problem occur on the free-ed dll code, and memory/code area belong some routine which I do not know, bcoz the debugger's stack only show the ntdll or vclbpl. That reason I could not show you the code where the error start from. Beside, the problem on occur with this DLL, which had DsPack (DirectShow, DirectX), it did not occur on other DLLs. Basically, I had 2 PCs, both also running the same program - Host and DLL. 1 PC run as Server and the other as Client, like remote control system. The client will automatically launch the DLL after server had manually launch the DLL (again via TWSocket), it will LoadLibrary and the call PluginInit to create the FORM. FYI, the closing problem only occur on client PC not the server PC. How it was closed? When server DLL's close by clicking the 'X' or press Alt-F4, it will send MDC_EXIT to the client PC, on received MDC_EXIT the client PC will call PostMessage WM_CLOSE and it was trigger from the timer event - ProcessQue. During the closing process, it will inform the Host by PGII_PLUGINFREE and give the estimate time period to free the close FORM. After cleaning up all the things it again inform host by PGII_PLUGINCLOSED, it ready to be free/unload. From the host program, it used timer to check for unload the DLL, before it really free the DLL, it call PluginExit to double confirm, otherwise it force to free the FORM. as the code given. So, I was sure that the PluginExit will not be call during the FORM closing process. Beside, if the client PC do not run as broadcaster, ie access the DsPack components load Mpeg file for streaming video and audio to server, the problem of closing never occur. Hope this could help you to understand to my problem. Question, usually take how long for a DLL with form to do complete cleanup? How can I send the actual code to your private email (only the DLL) . Regards KL Chin "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:41c7e9f2@newsgroups.borland.com... > > "KL Chin" <klchin@1asia.com.my> wrote in message > news:41c7b41a@newsgroups.borland.com... > >> Sorry, I will not able to show the complete code, it was too big. > > I don't want the complete code. Only the parts that are relavant to this > discussion - the code involved in shutting down the DLL and application. > >> BTW, not I wanted to access the DLL after it is freed. It was some >> how called during the unload/closing process and it was always had >> problem when Server issue a close command. > > Then your shutdown code is faulty. That is why I asked you to show it. > >> PostMessage( Handle,WM_CLOSE,0,0 ); >> PostMessage( Handle,WM_DESTROY,0,0 ); > > Do not destroy the Handle. TForm will do that for you automatically when > appropriate. > >> __declspec(dllexport) int WINAPI PluginExit( void ) > > When does the application call this? > >> if ( frMxCast ) > > Are you guaranteeing that the application never calls PluginExit() while > the > form is in the process of closing itself? If not, then you may have a > potential timing issue where frMxCast is not NULL yet but the form and > PluginExit() are both going to try to free the same memory multiple times. > >> __declspec(dllexport) int WINAPI PluginInit( HWND hWnd, viPluginInTInfo >> lpInTInfo ) > > When does the application call this? > > Nothing in the code you have shown indicates where the actual error is > occuring. But then, you did not show any of your application code at all, > either. It is not very helpful to show the DLL code without showing the > application code that is calling the DLL code. > > > Gambit > >
Technical Details
Message-ID:
<41c80c8a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41c78d36@newsgroups.borland.com> <41c79929$3@newsgroups.borland.com> <41c7a03a@newsgroups.borland.com> <41c7a7df$1@newsgroups.borland.com> <41c7b41a@newsgroups.borland.com> <41c7e9f2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bd28311fbf37010b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "KL Chin" <klchin@1asia.com.my> Newsgroups: borland.public.cppbuilder.nativeapi References: <41c78d36@newsgroups.borland.com> <41c79929$3@newsgroups.borland.com> <41c7a03a@newsgroups.borland.com> <41c7a7df$1@newsgroups.borland.com> <41c7b41a@newsgroups.borland.com> <41c7e9f2@newsgroups.borland.com> Subject: Re: Close Form in DLL Date: Tue, 21 Dec 2004 19:44:05 +0800 Lines: 113 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 219.93.184.30 Message-ID: <41c80c8a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1103629450 219.93.184.30 (21 Dec 2004 03:44:10 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail