Hello all.  Hopefully an experienced person can help me with this.  I have written a small program that uses regsvr32.exe to register a dll on system startup.  I also put in a createfile check to see if the dll exists before trying to register it.  My problem is that it runs fine when I manually execute it but when I have it loaded on system startup (Registry) it does not find the dll and also fails to register it.  The only thing I can think of is that the cpu is being used heavily at startup and might mess it up somehow so I added an invoke Sleep call to wait for 30 seconds before running.  This doesn't seem to work either.  Is there something simple I am missing?
Posted on 2005-08-15 09:11:45 by Desp
How do you create the registry entry?
Something like this should work.

SOFTWARE\Microsoft\Windows\CurrentVersion\Run
"app_name"="C:\WINDOWS\System32\regsvr32.exe /s C:\full_path_to_the_app\file.dll"

You could also load the library without regsvr32. just load the dll ( LoadLibrary), GetProcAddress of DllRegisterServer function. And call it. That's it.
Posted on 2005-08-15 10:21:57 by arafel
Hmmmm. Very interesting.  Actually my program is the one that is being called on startup:
SOFTWARE\Microsoft\Windows\CurrentVersion\Run
"My_app"="C:\Program Files\My App\Prog.exe"

First, my program uses a createfilea call to see if the dll is present and if not it shows a message box.  Then if the dll is present it calls regsvr32 and registers the dll.  The problem is that my program works fine when I manually run it but when it is set to startup in the registry it never finds the dll in the createfile check and can't register the dll.
Posted on 2005-08-15 10:47:14 by Desp
Check the lpFileName parameter passed to CreateFile.
For example if the dll located in the same dir as the application and you specify it without full path it might not work, because current working path could be set to to something else.
Posted on 2005-08-15 11:03:37 by arafel
Ah yes, I was trying to use GetCurrentDirectory when I should have been using GetAppPath.  Thanks a lot for all the help.  :D
Posted on 2005-08-15 12:32:17 by Desp