Re: DllMain
- From: "William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx>
- Date: Wed, 12 Oct 2005 22:50:55 -0400
"Menker" <Menker@xxxxxxxxxx> wrote in message
news:eXDHbd4zFHA.908@xxxxxxxxxxxxxxxxxxxxxxx
>I add to my VC project a dll. I want to add into the dllmain function
> SetTimer function and a callback routine to serve it. The main project has
> got its own windows and probably message pump. Do I have to add message
> pump
> or anything else to the dll?
Two things spring to mind:
First, note this caution from the docs on DllMain
<quote>
Calling functions that require DLLs other than Kernel32.dll may result in
problems that are difficult to diagnose. For example, calling User, Shell,
and COM functions can cause access violation errors, because some functions
load other system components. Conversely, calling functions such as these
during termination can cause access violation errors because the
corresponding component may already have been unloaded or uninitialized.
</quote>
SetTimer() is a User function. Even if it works, you _shouldn't_ do that.
Second, why do you think you need a DLL? I'm not saying you don't
necessarily, just asking.
But the most canonical thing to do would be to call SetTimer() after your
basic initialization. If the DLL is implicitly loaded, SetTimer() gets
called in advance of your initialization. If you explicitly load it, then
that is better but then the question is why?
Regards,
Will
.
- Follow-Ups:
- Re: DllMain
- From: Menker
- Re: DllMain
- References:
- DllMain
- From: Menker
- DllMain
- Prev by Date: Re: passing a string to a C++ function
- Next by Date: Re: passing a string to a C++ function
- Previous by thread: DllMain
- Next by thread: Re: DllMain
- Index(es):
Relevant Pages
|