Tech Support > Microsoft Windows > Development Resources > Use dll from specified directory?
Use dll from specified directory?
Posted by Gernot Frisch on June 25th, 2003


Hi,

Can I have my (and only my) app seek for a dll in a folder like:
C:\Programme\MyDlls\...

Thank you,

-Gernot

In order to reply, revert my forename.

------------------------------
DiNGS Game Basic + ClipChap
http://www.Dream-D-Sign.de


Posted by david lindauer on June 25th, 2003


yes, just specify the full path name of the DLL in the LoadLibrary call.

David

Gernot Frisch wrote:


Posted by Sten Westerback on June 26th, 2003


.... unless he means how he can affect automatically loaded
libraries. The quick answer for that is that you can't unless
you are the first to load such an DLL into memory (after which
the same code base will be reused by other apps).

If he want to restrict access to the DLL then NTFS folder
protection will do that... it can even be done programmatically.

A final option would be to install a global hook that will detect
if the DLL is loaded and then take care of it (by killing the
application?).

- Sten
"david lindauer" <camille@bluegrass.net> wrote in message
news:3EFA1640.DE93D1DD@bluegrass.net...




Posted by Gernot Frisch on June 26th, 2003



Not security, I simply want to have my dll located in Company/Shared/ in
order to have other prgs not using it if another dll with the same name
might exist on the computer.
-GF

LoadLibraray - good idea!



"Sten Westerback" <sten.westerback@NO_SPAMnokia.com> schrieb im Newsbeitrag
news:FrAKa.38974$ws6.781508@news2.nokia.com...


Posted by Dmitry Davletbaev on June 26th, 2003


I guess the best way to do this is to put your DLL in the same directory as
your program. The DLL search order begins with directory where program
exists so it will be guaranteed that your DLL is loaded instead of others.
And you don't need to specify full path to load library.

--
Dmitry Davletbaev
hara@mgn.ru

"Gernot Frisch" <tonreG.Frisch@Dream-D-Sign.de> wrote in message:
news:bdf027$s7rpg$1@ID-37212.news.dfncis.de...


Posted by Gernot Frisch on June 27th, 2003


But I have several programs in different folders that should use the same
..dll.
-Gernot


"Dmitry Davletbaev" <hara@mgn.ru> schrieb im Newsbeitrag
news:766fdb.r37.ln@pandora.maginfo.net...


Posted by Patrick Philippot on June 27th, 2003


Gernot Frisch wrote:
Just wondering why the solution with App Paths suggested in my previous
message is not satisfactory? Are these programs launched with
CreateProcess? A lot of commercial applications use App Paths to share
DLLs in a single folder while isolating them from other apps. Norton /
Symantec applications in the first place...

--
Patrick Philippot
MainSoft Consulting Services
www.mainsoft.xx
(replace .xx with .fr when replying by e-mail)




Posted by Gernot Frisch on June 27th, 2003


I can do this easily, but some of the programs are written in VB. Don't tell
me, I know it's crap! But they say it 'easier' - well depends on what you
call 'easy'...

Anyway. I can put the dll in the VB program's directory then.

Best regards,
Gernot



"Patrick Philippot" <patrick.philippot@mainsoft.xx> schrieb im Newsbeitrag
news:bdhh54$d69$1@biggoron.nerim.net...



Posted by Patrick Philippot on June 27th, 2003


Gernot Frisch wrote:
This shouldn't change anything. If your program is written in VB, you do
have Declare statements in your code referring to the DLLs exporting the
functions you're using. The VB runtime will do a LoadLibrary against
these DLLs when needed. And the App Paths entry for your program should
then be used to find your DLL.

Just try.

--
Patrick Philippot
MainSoft Consulting Services
www.mainsoft.xx
(replace .xx with .fr when replying by e-mail)




Posted by Patrick Philippot on June 27th, 2003


Gernot Frisch wrote:
Just to be sure, I have just written a small VB6 test program making a
call to a DLL that is not in the PATH and not in the same folder as the
program itself. I created an entry for this program in App Paths and I
could successfully call the exported DLL function. After removing the
App Paths entry, the program failed which is what I expected.

--
Patrick Philippot
MainSoft Consulting Services
www.mainsoft.xx
(replace .xx with .fr when replying by e-mail)




Posted by Gernot Frisch on June 27th, 2003


Thank you very much. Really great help.
-Gernot


"Patrick Philippot" <patrick.philippot@mainsoft.xx> schrieb im Newsbeitrag
news:bdhnhq$hri$1@biggoron.nerim.net...


Posted by Patrick Philippot on June 27th, 2003


Sin wrote:
Alex,

You just have to read my first answer to the initial message of this
thread.

--
Patrick Philippot
MainSoft Consulting Services
www.mainsoft.xx
(replace .xx with .fr when replying by e-mail)




Posted by John Brown on June 28th, 2003


"Patrick Philippot" wrote...

For what it is worth, the thread in Google Groups looks like this:

1 Gernot Frisch 25 Jun 2003
\-2 david lindauer 25 Jun 2003
\-3 Sten Westerback 26 Jun 2003
\-4 Gernot Frisch 26 Jun 2003
\-5 Dmitry Davletbaev 26 Jun 2003
\-6 Gernot Frisch 27 Jun 2003
\-7 Patrick Philippot 27 Jun 2003
\-8 Gernot Frisch 27 Jun 2003
|-9 Patrick Philippot 27 Jun 2003
\-10 Patrick Philippot 27 Jun 2003
|-11 Gernot Frisch 27 Jun 2003
\-12 Sin 27 Jun 2003
\-13 Patrick Philippot 27 Jun 2003


Your first message (\-7 Patrick Philippot 27 Jun 2003) says:

but there is no previous message.

For the original poster:

Posted by Patrick Philippot on June 28th, 2003


John Brown wrote:
As seen from my news server, my first message is a follows (dated
06/25/2003):

"""""""""""""""""""""""
Gernot Frisch wrote:
Hallo,

That's why the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths
registry key is there. However, be aware that this will only work for
applications launched from the shell (ShellExecute). CreateProcess (as
well as console applications) ignores this setting if I remember well.

<quote>
Registering Application Path Information
The system supports "per application" paths. If you register a path,
Windows sets the PATH environment variable to be the registered path
when it starts your application. You set your application's path in the
AppPaths subkey under the HKEY_LOCAL_MACHINE key. Create a new key using
your application's executable file name as its name. Set this key's
default value to the path of your executable file. The system uses this
entry to locate your application if it fails to find it in the current
path - for example, if the user chooses the Run command on the Start
menu and includes only the file name of the application, or if a
shortcut icon doesn't include a path setting. To identify the location
of .dll files placed in a separate folder, you can also include another
value entry called Path and set its value to the path of your .dll
files, as follows:

HKEY_LOCAL_MACHINE
Software
Microsoft
Windows
CurrentVersion
App Paths

Application Executable Filename = path

Path = path

The system will automatically update the path and default entries if the
user moves or renames the application's executable file using the system
shell user interface.

</quote>

"""""""""""""""""""""""

Something wrong with this thread...

--
Patrick Philippot
MainSoft Consulting Services
www.mainsoft.xx
(replace .xx with .fr when replying by e-mail)




Similar Posts