Re: Where is my DLL?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernie Ryan wrote:

> Juergen Luethje wrote:
>>
>> Hi all,
>>
>> how can a DLL find the path where it was loaded from?
>> I need it because the DLL must read an INI file that is in the same
>> directory as the DLL. Of course I don't know, where the users will
>> install it.

<snip>

>> This not only seems somewhat crazy to me smile, I think there can be at
>> least two problems:
>> a) If the user renames the DLL, GetModuleHandle() will not return its
>>    handle any more.
>>
>> b) If the name does not include a path and there is more than one
>>    loaded module with the same base name and extension, you cannot
>>    predict which module handle will be returned.
>>    [MSDN Library]
>>
>>
>> What can I do? Thanks in advance for any hints.

<snip>

> Juergen:
>
> Either install the dll with it's location specified in the registry
> or place it in the system directory.

Unfortunately, the installation process is not under my control.
It would probably not even have much effect when I recommend the user to
put the DLL into this or that directory.
The DLL is a plugin for Total Commander (TC). Many users have dozens of
plugins, and many people have their own system how to organize the
plugins.
The user can install the plugin manually, or by using a semi-automatical
procedure provided by TC. In any case, TC writes the location of the
plugin into its own INI file. But I also don't know where TC's INI file
is on a given machine.

> The only way to prevent the user from renaming it is to
> make the dll read only so the user will realize that he should
> not be renaming it.

I just tested it, making the DLL read-only, system, and hidden.
Renaming was easy, it worked the same way as without these attributes
(using Total Commander on Windows 98).

Maybe the risk that someone will rename the DLL is not soooo high.
However, I would highly prefer that renaming it would not influence
its functionality.

Regards,
   Juergen

-- 
Have you read a good program lately?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu