DLL - Calling application notification upon destroy

Is there any way to detect when an application that is calling my dll is
about to be destroyed?

I need to close several files if the calling application has not done so,
therefore I need to detect when the calling application is about to be
destroyed and clean up the files and variables I have used in the dll.


0
jestock1 (39)
11/29/2003 6:49:12 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
346 Views

Similar Articles

[PageSpeed] 21

You need to implement DllMain, the handle your cleanup tasks when you
receive a PROCESS_DETACH notification.

Check out:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_initialize_non.2d.mfc_dlls.asp

"Joe Estock" <jestock@NOSPAMnutextonline.com> wrote in message
news:vshql393gd63ba@corp.supernews.com...
> Is there any way to detect when an application that is calling my dll is
> about to be destroyed?
>
> I need to close several files if the calling application has not done so,
> therefore I need to detect when the calling application is about to be
> destroyed and clean up the files and variables I have used in the dll.
>
>


0
11/29/2003 10:11:31 PM
Yes and no - read very CAREFULLY what you may and more important may NOT do
on PROCESS_ATTACH/DETACH...

"Tom Jones" <tomjones16@hotmail.com> wrote in message
news:%23Um9%23WstDHA.2368@TK2MSFTNGP09.phx.gbl...
> You need to implement DllMain, the handle your cleanup tasks when you
> receive a PROCESS_DETACH notification.
>
> Check out:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_initialize_non.2d.mfc_dlls.asp
>
> "Joe Estock" <jestock@NOSPAMnutextonline.com> wrote in message
> news:vshql393gd63ba@corp.supernews.com...
> > Is there any way to detect when an application that is calling my dll is
> > about to be destroyed?
> >
> > I need to close several files if the calling application has not done
so,
> > therefore I need to detect when the calling application is about to be
> > destroyed and clean up the files and variables I have used in the dll.
> >
> >
>
>


0
someone (38)
11/30/2003 10:53:21 AM
Very helpful John - why do people feel the need to interject without
actually helping the person who originally asked the question?

Joe, what John is referring to is that while your DllMain function is
executing a special critical section, normally referred to as the "process
critical section" is held.  So certain things, anything that would cause
DllMain to be called again for example, cause very difficult to debug
deadlocks.

Here is an excellent explaination of the problem by Matt Pietrek:

http://www.microsoft.com/msj/archive/S220.aspx

TJ

"John Smith" <someone@some.where.inter.net> wrote in message
news:%23rwGpAztDHA.556@TK2MSFTNGP11.phx.gbl...
> Yes and no - read very CAREFULLY what you may and more important may NOT
do
> on PROCESS_ATTACH/DETACH...
>
> "Tom Jones" <tomjones16@hotmail.com> wrote in message
> news:%23Um9%23WstDHA.2368@TK2MSFTNGP09.phx.gbl...
> > You need to implement DllMain, the handle your cleanup tasks when you
> > receive a PROCESS_DETACH notification.
> >
> > Check out:
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_initialize_non.2d.mfc_dlls.asp
> >
> > "Joe Estock" <jestock@NOSPAMnutextonline.com> wrote in message
> > news:vshql393gd63ba@corp.supernews.com...
> > > Is there any way to detect when an application that is calling my dll
is
> > > about to be destroyed?
> > >
> > > I need to close several files if the calling application has not done
> so,
> > > therefore I need to detect when the calling application is about to be
> > > destroyed and clean up the files and variables I have used in the dll.
> > >
> > >
> >
> >
>
>


0
11/30/2003 8:58:15 PM
Reply:

Similar Artilces:

VBAProject Password upon exiting Excel
When I close Excel I get get a popup asking for a VBAProject Password. I have to hit cancel 6 times to get Excel to close. How do I get it to stop asking for the password? Saved from a previous post: There have been a few problems associated with Google's Desktop Search. Do you have that installed on your pc? If yes, maybe disabling that COM Add-In will help. One way to turn it off: In excel, Tools|customize|Commands tab|Tools Category Scroll down the commands listbox and Drag "COM Add-ins..." to under Tools|Addins (It seems to make sense there.) Then close up that dia...

Set Application Page permissions in WSS 3.0
Example: Using the HelpDesk template, how can I apply permissions to Service Rep and Mgr Home pages? TIA! -JS ...

Protecting My Assembly DLL
Hi All, All you know that, if you develop dotnet application, It s not hard to use it by someone, no matter it s an application or assembly dll I tried a solution against this, Think about I have an application consist of "one login form, launcher", "one main application, lets say MDI form" form and an assembly dll (real business application thatt shouldn't be used or decompiled by others) If I encrypt my dll file with another delphi application before deployment When user runs my delphi launcher application (consists one login form), after auth...

deploy needs debug dll?
I'm wondering if anyone has seen this. First, several computers have a previous version of our deployment. I've sent my executable and dlls out as pre release so some of my clients could take the next version around the block and I could get feedback. That works fine. And I've checked, I have not deployed a dll called MSVCR71D.dll in that previous version. Now, when I do an install of the new version on a computer, the app won't run, it is looking for that dll. The exact same app and dlls when laid over an old version don't need the dll. I don't think I've ...

Hyperlinks from MFC application to Excel
How can my MFC based application use a hyperlink to open a specific sheet in an excel-workbook? I can use this hyperlink from Word or Excel: file:///c:\doc\Test.xls#'Page3'!PrintArea Regards, Petter In article <u#Tsr9rdGHA.3792@TK2MSFTNGP03.phx.gbl>, Petter says... > How can my MFC based application use a hyperlink to open a specific sheet in > an excel-workbook? > I can use this hyperlink from Word or Excel: > file:///c:\doc\Test.xls#'Page3'!PrintArea Have you tried ShellExecute()? -- stefan I have tried ShellExecute but it does only half the j...

how to NOT get a notification message for an arriving spam email?
Hi, I use the rule wizard to set up some rules to direct spam emails to my "spam" folder. I also turn on the option "Display a notification message when new mail arrives". The thing is, I don't want to get a notification for arriving emails that will be directed to the spam folder. Would it be possible? It's quite annoying to get so many junk notifications. Please help. Thanks. Tony What you're looking for is not possible. Sorry, it's all or nothing. >-----Original Message----- >Hi, > >I use the rule wizard to set up some rules to...

Application depends on msvcp71.dll and msvcp71d.dll in the same time
Hello I started testing my application written entirly on machine running XP Pro (VS 7.1). After installing the application (built in the debug mode) on fresh installation of Windows 98 SE I have discovered that it requires dlls from debug and non-debug modes (for example: msvcp71.dll and msvcp71d.dll, msvcr71.dll and msvcr71d.dll). The application uses a few external libraries but they are linked statically. Is this natural ? Thanks si Debug mode will require the debug versions(msvcp71d.dll, etc...) and the release mode will require the release versions (msvcp71.dll, etc...). Win...

Docking ToolBars Loaded by a DLL
Hello everyone! I'm Working on a dll that aims to add several toolbars in an existing mfc application. I would like to dock all of my toolbars but the only way to access to the Mdi frame window of the application is the handle. How can I dock my toolbar in the main application window ??? Thanx. Olivb. I dont know what you are asking. You can get the main window using AfxGetMainWnd will give you main window from another DLL. Typically you should make other DLL an MFC Extension DLL. This avoid use of AFX_MANAGE_STATE macros. The fact that you are in another DLL will not impact the...

msoeacct.dll and msident.dll
Every time I try to use Outlook 2002 I get a c:windows/system32/msoeacct.dll or msident.dll errors...I have tryed several things from the knowledge base of microsoft and thus far nothing has worked. I am loosing patience with this....what do I have to do to fix this...reinstall windows xp? I have already reinstalled my office and have even reinstalled my internet explorer. I have the most recent version, 6. Is there anyone who has had these problems and can you help me? Thanks. PJ Shuart ...

Messages from user folders disapper upon deletion (do not go to the Deleted Items folder)
PROBLEM I have set up several rules to manage incoming emails. The rules direct the emails to topical user-created folders based on either who the sender is or the content of the subject line. When a message comes is, say with the word "Adobe" in the subject, the rules put it in a folder called "Computer Stuff". This works well. I have several topical folders and the rules do a good job at directing the messages to the right one. The problem is that when I delete a message that has been routed by the rules to a user-created folder, it disappears into the ether. In o...

Application message
I would like to display a message to a user, even if the Access application has been minimized. Msgbox will do this, but it's modal, it stops VBA. Is there an application directive that will maximize the Access window via VBA? On Dec 12, 7:39 pm, Leif <L...@discussions.microsoft.com> wrote: > I would like to display a message to a user, even if the Access application > has been minimized. Msgbox will do this, but it's modal, it stops VBA. Is > there an application directive that will maximize the Access window via VBA? Yes, this can be done. What triggers the me...

Notification when Activity is linked to a Case
Hi, I am using the Tracking ID and would like to know if it's possible, whenever a customer answers an email from the support and the email is attached to the matching case, to trigger a workflow rule that will notify the owner of the case. I am not sure it is possible to base a WF rule on the "Activity appended to a Case" event... Thanks Eric In the v1.x releases, activities can not trigger workflow. You could do something manually via a post-callout though. Matt Parks MVP - Microsoft CRM ---------------------------------------- ------------------------------------...

using VB CListCtrl from a C++ dll
First off, I want to acknowledge my general lack of understanding of the nuts and bolts of the windows messaging model. I saw a similar post ("How to operate the ListCtl in a worker thread") that alluded to thread issues being my problem. To the point: I have a VB app (actually Excel VBA). I load a UserForm (uf1) modeless and push a command button on this form that initiates a call to an MFC C++ dll function. I would like to load a VB ListView control on uf1 while processing within the c++ dll. Given that I can send the hWnd of the ListView control to the dll, I assumed I...

MFC DLL vs. Win32 DLL + MFC (small size is important)
I've noticed that there is smaller size of DLL when created like Win32 DLL project and then linked MFC as static lib, then when it is created as MFC DLL project. Is this truth? I'm trying to make my dll as smaller as possible. ...

email to application -- yearning for a sendmail feature in Exchange
In my Unix days (long ago), we could set up an email alias that would pipe the contents of a message into an application. Sendmail would perform it's duties by opening a pipe to the application and feeding the text of the message off to this application on stdin. It was a great feature. Now I live in the Exchange world (2003 version) and I could use that functionality but I can't find any way to do this. My need is to print any message that arrives in a mailbox. I want to do this server-side, so I don't have to leave outlook running somewhere just to kick off the rules. ...

Visio asking for Visual Basic for Applications.............................HELP!!! tia
My work laptop came with visio 2003 and when I try to merge an excel table it is asking for the Visual Basic for Applications. Is this something I can download some where? Thanx in advance. I suspect that it is included in the trial version. CAVEAT becareful that you don't over write your production legal system with the trial software. I'd suggest you go back to those that loaded it onto your system. Another source is the VBA6.2 SDK which is available for download from MS. Al "Boll Weevil" <dryer@maytag.com> wrote in message news:i30aa01k5fqegpg8rpt3ms5k0hgtthli2q@4...

How to Play audio file through VC++ application...
Hi i am working with audio playing through VC++ application. Currently i am using DirectSound API to play the audio file of PCM format (Wav). But my this code does not play the wav files with MPEG-Layer 3 fomat. Could anybody please help me out by any code sample the plays audio file of any format... Thanks in advance... Mujtaba This is what I started out with. It is a simple interface to the sound card. http://www.codeguru.com/Cpp/G-M/multimedia/article.php/c1587 You may want to check out these... http://www.codeguru.com/Cpp/G-M/multimedia/audio/article.php/c4739/ http://www.codeproject...

Timer in a standard dll
I have an MFC application with a regular MFC dll. In the dll, I need some timer but I don't know how to do it since there is no window in the dll and creating a windows class for that would make it run in the class object which is not what I want. Is there any solution for that? Regards I. lesher Gur wrote: > I have an MFC application with a regular MFC dll. In the dll, I need some > timer but I don't know how to do it since there is no window in the dll and > creating a windows class for that would make it run in the class object > which is not what I want. >...

ModalDialog in DLL
Hi, we have a problem using MFC in a DLL. We are trying to use a third party dll that wants to open a modal dialog using MFC 7. Our application is using MFC 4.2. When the DLL tries to open the dialog the application crashes :( We think that it has something to do with the dialog that wants to block the main window. If the DLL is doing something like AfxGetMainWnd() how does it get the right one? I mean does the DLL have some CWinApp-Object?? i'm confused, Andreas ...

where can I download gpconn.dll and gpconnet.dll?
Hello Somebody know where can I download gpconn.dll and gpconnet.dll? If you have the link to download this files I'll apreciate it so much. Best regards. A.L. I believe you need to request these from GP support. -- Victoria Yudin Dynamics GP MVP Want to use Crystal Reports with GP? http://www.flex-solutions.com/gpreports.html blog: http://www.victoriayudin.com "see07" <see07@yahoo.com> wrote in message news:2b31e7c7-8e16-487c-a20c-4a0db17fff7c@s31g2000yqs.googlegroups.com... > Hello > > Somebody know where can I download gpconn.dll...

Does anyone know of a software application for Pivot tables other.
We have some very complex pivot tables in Excel that unfortunately are not very stable or flexible when you make changes. The data list is used to generate multiple pivot tables in the same workbook but the data and the number of records can change frequently. One time we might have 18000 records and the next time we might have 2500 records. So far it seems that everytime we have to change the data we have to reset the data source range for each pivot table. I believe each pivot table was copied via Edit, Move or Copy, rather than being generated as anew pivot table or based on anot...

Debugging exeption NTDLL.DLL
Hello guys, I get termination message "First-chance exeption in .exe (NTDLL.DLL)... Invalid Handle" while debugging an MFC project. Is somebody has any idea how to resolve this prolem? Thank you. Kogan, > I get termination message "First-chance exeption in .exe (NTDLL.DLL)... > Invalid Handle" while debugging an MFC project. > Is somebody has any idea how to resolve this prolem? Its not necessarily a problem, see: http://support.microsoft.com/?id=105675 -- Regards, Kobi Ben Tzvi "Kogan Shmuel" <kogan-s@bezeqint.net> wrote in message new...

svchost.exe
Hi, I reformated my pc last week and after installing Symantec antyvirus and windows defender task manager sometimes it shows CPU usage of over 95% even when wasn't running anything. I uninstalled both programs and it seem to have fixed the problem. But now there is a svchost.exe - application error. Instruction at 0x00b42740 referenced memory at 0x00b42740. the momory could not be written. OK to terminate or CANCEL to debug the program. I'm running Window XP Media Center Edition Version 2002 SP3 I don't know if these two issues are related or not. Can anyone ...

Dll Data Sharing
I have a dll that loads data in CArray<CSomeClass,CSomeClass> from a file. The file contains the serialized CSomeClacc object(s). The array is populated once the dll is loaded. My problem is when a second process loads the same process it again loads the same file in the CArray in its address space, I want to share my CArray so any subsequent calls except first call does not load the object's CArray but shares the same copy of the already loaded CArray. How Can I implement it? Regards Tariq You can't share CArrays, or any other MFC structure, in a DLL. This is because the s...

Can Limited Users access Doc&Set->Application Data?
Can a Limited User with limited privileges access the C:\Documents and Settings\Application Data\... folder? I'm seeing an application that stores stuff there, but the application seems not to be able to store stuff there when it's run by a limited user. Kinda makes it hard to run any application with a Limited User account. Is there some way other than telling everyone you can't run anything as a Limited User? Is there something the program can do, or something the Administrator can do, other than give everyone full privileges? "Susan Rice" <srice1@cox.net> wrot...