Highlighted
Absent Member.
Absent Member.
1599 views

[archive] Setting Search path for WinApi DLL's

[Migrated content. Thread originally posted on 30 October 2003]

I am doing CALL "gdi32.dll" to load the dll, but the call fails because it can't find it. The dll resides in windows\system folder on Win98 and WinXP but in a different folder on Win2000.

Has anyone managed to ovecome this problem without giving an explict path in the call statement like CALL "c:\windows\system\gdi32.dll"?

I would ideally like to have my program do a generic CALL that will place the dll in the correct folder and not to have a seperate config file according the client.

Help!!!
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Setting Search path for WinApi DLL's

You could use the ACCEPT FROM ENVIRONMENT statement to get environment variables such as windir, systemroot, OS and even ComSpec to help you figure out the default windows and system directories.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Setting Search path for WinApi DLL's

Provided that the system path includes the path to the Windows and System directories, your experience might be a part of a known phenomena.

This probably happens because your FILE-PREFIX is set, and does not include the Windows system directory.
This has been corrected for an upcoming version, which will enforce a search in the Windows and the System directory regardless of the FILE-PREFIX setting if nothing is found when you are searching for a DLL.

A solution to this would be to have a dynamic FILE-PREFIX that you calibrate upon installation, e.g. you create it as a part of the installation, and when you create it, you also make sure to call the Windows API functions GetSystemDirectory and GetWindowsDirectory. The outcome of these then, should be applied to your other settings of the FILE-PREFIX variable.

Sorry for the inconvenience of this.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Setting Search path for WinApi DLL's

Hi all,
I think that you can solve your problem by setting "." in the code_prefix variable.

e.g.

accept old_prefix from environment "code_prefix"
set environment "code_prefix" to "."
[...]
call "gdi32.dll"
[...]

set environment "code_prefix" to "."

hope this help.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Setting Search path for WinApi DLL's

Thank you Luca. It does work. I am uncertain to why it does. Can you shed some light on it?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Setting Search path for WinApi DLL's

Hi SRFish,
the reason it works is because setting "."
in the code_prefix activates the smart
search for the DLL.
The runtime then looks for the DLL in the
Windows and windows\system directory whenever is your OS (it takes care about
the various WINNT, WINDOWS, SYSTEM, SYSTEM32, etc).

I read it in documentation, but I can't find
it out no more...

I'll still try, and if I will hit it I'll post it for
your convenience
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.