Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regsrv32 or Do you have to "register" DLLs? 1

Status
Not open for further replies.

davemassey

Programmer
May 10, 2004
19
US
I've heard that you sometimes have to register DLLs and I'm wondering 1) is that correct? and 2) what are the requirements for doing so? and 3) how can I tell that a DLL needs to be registered.

Thanks!

Dave

 
>1) is that correct?

Not neccesarily. Regular DLLs is just accessed through the PATH variable. However, if the DLL exposes a COM interface it should register.

>2) what are the requirements for doing so?
Calling its DllRegisterServer function.

>3) how can I tell that a DLL needs to be registered.
Check if it has a DllRegisterServer function.

Code:
typedef HRESULT (STDAPICALLTYPE* FuncDllRegisterServer)();
...

// Load the dll
HMODULE hDLL = AfxLoadLibrary(name);

if (hDLL!=0)
{
  // DLL loaded

  // Access the DllRegisterServer function
  FuncDllRegisterServer registerServer = (FuncDllRegisterServer)GetProcAddress(hDLL, "DllRegisterServer");	

  if (registerServer == 0)
  {
    // No such function - can't be registered
  }
  else
  {
    // It can be registered...so register it
    registerServer();
  }
}


/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
It's True.. some, if not all, need to be registered. It depends on whether Windows needs to make a system call to the library or not. Certainly with *.ocx files, you need to use regsvr32. A way to tell is if the .dll is meant to be located in the 'system32' directory (or 'system' directory). It's a little 'hit and miss', but i quite often install my app on an intended system, thats blank, and try to run it. Windows will quickly tell you what libraries are missing. If you know you've installed them on the PC, then you'll have to register them.
 
if you put the dll in %windir%\system32 you may be assured what the dll always will be found. Also you may add .dll to system variable PATHEXT and you will be assured so what the dll fill be accessible in any locations indicated by system or user variables PATH

Ion Filipski
1c.bmp
 
If you have write permissions in the %windir%\system32 directory, that is.
 
%windir%\system32 is intended for the OS. I wouldn't feel comfortable in putting my stuff there...but then, maybe its just me.

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
>that does a lot of programs...

And thus its good?

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
if the uninstaller removes them properly, then is Ok. Else you should be careful. But you should be careful anyway.

Ion Filipski
1c.bmp
 
I don't think it is a good idea to put them under %windir%\system32 and here are the reasons why:

1) First of all if could NOT have write permissions in the %windir%\system32 if you are not an admin or power user (on the NT kernel based operating systems). Thus, a regular user will not be able to use you software. Is that what you want?

2) Copying stuff in that dir. is simply lame. It is much more elegant to modify the path global env. variable and keep your modules in your separate dir. structure.
 
Thanks for the help. That info will really come in useful!

-Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top