Welcome, Guest
Guest Settings
Help

Thread: Location of custom DLLs


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Feb 15, 2017 3:07 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Location of custom DLLs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 5, 2016 12:39 PM
Hi,
I have a DLL that I want installed so that it is "system-wide", i.e. there is no need to specify the exact path to it by other apps. Where is the appropriate location, WINDOW\SYSTEM32? I am using InstallAware 2012 RAD Studio Edition.

Thanks
Goran
Remy Lebeau (Te...


Posts: 7,530
Registered: 12/23/01
Re: Location of custom DLLs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 5, 2016 1:02 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran wrote:

I have a DLL that I want installed so that it is "system-wide", i.e.
there is no need to specify the exact path to it by other apps.

You need to either:

1. place the DLL in any folder that is available to Windows's DLL search
path.

2. register the location of the DLL in the "Known DLLs" key in the Registry.

This is all covered in the documentation on MSDN:

Dynamic-Link Library Search Order
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspx

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Re: Location of custom DLLs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2016 11:51 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks Remy!
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Re: Location of custom DLLs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 5:31 AM   in response to: Goran Ekstrom in response to: Goran Ekstrom
More issues!

The DLL installs fine but I am trying to get my DLL known to windows. If I run regsvr32 I get a "Missing DLLRegsisterServer" error message. After googling about it seems this method must be implemented in the DLL for the DLL to be "self registering" but I cannot find any good "how to" about this method.

Am I complicating things?! Is there an easier way to make DLL "known" to Windows? The KnownDLL registry entry seems to not be accessible/protected.

Thanks
Goran
Remy Lebeau (Te...


Posts: 7,530
Registered: 12/23/01
Re: Location of custom DLLs [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 12:02 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran wrote:

The DLL installs fine but I am trying to get my DLL known to windows.

I already explained in my previous reply how to do that. The KnownDLL registry
key is the easiest solution.

If I run regsvr32 I get a "Missing DLLRegsisterServer" error message.

regsvr32 only applies to (un)registering COM objects that are implemented
in DLLs. Does your DLL implement a COM object? I'm guessing no, since DllRegisterServe()
is a required function for COM DLLs, and Delphi's COM framework handles that
for you.

Am I complicating things?!

Yes.

Is there an easier way to make DLL "known" to Windows? The
KnownDLL registry entry seems to not be accessible/protected.

Yes, it is accessible, but since it is under the HKEY_LOCAL_MACHINE hive,
your installing code needs to run elevates with admin rights. Are you doing
that?

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Re: Location of custom DLLs [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 2:18 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Is there an easier way to make DLL "known" to Windows? The
KnownDLL registry entry seems to not be accessible/protected.

Yes, it is accessible, but since it is under the HKEY_LOCAL_MACHINE hive,
your installing code needs to run elevates with admin rights. Are you doing
that?

Well, I try to edit the KnownDLLs part in the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs) using REGEDIT in Admin mode but I get an error message "that the value could not be written" so I am assuming an installer will have the same problem, even with admin rights. Will it?
Remy Lebeau (Te...


Posts: 7,530
Registered: 12/23/01
Re: Location of custom DLLs [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 2:29 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran wrote:

Well, I try to edit the KnownDLLs part in the registry
(HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\KnownDLLs) using REGEDIT in Admin mode but I get an error
message "that the value could not be written" so I am assuming an
installer will have the same problem, even with admin rights. Will it?

Works fine for me when I try it, no error is reported. You must be doing
something wrong. By "in Admin mode", are you right-clicking on regedit and
selecting "Run as Administrator"? On Vista and later, regedit has a UAC
manifest, so it should always be running with elevated rights even if you
don't use "Run as Adminstrator".

Installers should be manifested for UAC so they run with elevated rights.
There should be no problem for an installer to write to the KnownDLLs key
if it has sufficient rights.

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Re: Location of custom DLLs [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 2:33 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
STOP! My bad, I had hardcoded the path to the DLL, calling LoadLibrary with just the dll file name works, sorry for the mess.

Works fine for me when I try it, no error is reported. You must be doing
something wrong...

FYI, I have now tested the KnownDLLs reg key on three Win10 Pro and an old Vista with same result, write protected. If I check permissions it is only the TrustedInstaller account that has full Control of the key, the rest is read only.
Remy Lebeau (Te...


Posts: 7,530
Registered: 12/23/01
Re: Location of custom DLLs [Edit] [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 3:07 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran wrote:

Tested on two Win10 Pro with same result.

Works fine for me on Win7. Must be a behavior change on Win10.

If I check permissions it is only the TrustedInstaller account that
has full Control of the key, the rest is read only.

On my Win7, admins have full access.

Looing at the key entries it is all Microsoft, no third party DLLs so
I am a little confused about if this really is the right place...

It should be, otherwise it wouldn't be documented as such. Most 3rd party
DLLs are simply private use and don't require registration in that key.
It is typically only used for DLLs that have to be shared amongst multiple
apps installed in different folders. Apps that are designed to work together
can use SetDllDirectory() or AddDllDirectory() instead of the KnownDLLs key.

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 90
Registered: 1/10/04
Re: Location of custom DLLs  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2017 3:01 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Code error
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02