Re: DllMain

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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



.



Relevant Pages

  • Re: SetTimer in DLL - Never triggered ??
    ... > I have initiated a 'SetTimer' routine within my Delphi DLL code. ... > in) IS processing Windows messages? ... > the DLL to popup a GUI Message box, my SetTimer procedure DOES get ...
    (borland.public.delphi.nativeapi)
  • SetTimer in DLL - Never triggered ??
    ... I have initiated a 'SetTimer' routine within my Delphi DLL code. ... in) IS processing Windows messages? ...
    (borland.public.delphi.nativeapi)
  • Re: DllMain
    ... Actually the dll is injected to the target process by a Win32 Hook so I ... COM initialization somehow in the dll, and since I've noticed that its ... >> SetTimer function and a callback routine to serve it. ... calling functions such as these ...
    (microsoft.public.vc.language)
  • SetTimer
    ... I can compile my dll that contains a call to SetTimer using eVC 4, ... I build my image using PB 4.2 (and the dll is included in that image), ... If I cover up the calls to SetTimer, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: MFC Support in DLLs
    ... > I have a DLL written in plain win32 that I want to add MFC support to. ... > having trouble with the DllMain function. ... settings that need to be changed, as well as the project workspace file ...
    (microsoft.public.vc.mfc)