Solved

Fixed Location of DLL

Posted on 2002-03-18
7
198 Views
Last Modified: 2010-04-05
In a lot of programs I have seen where the program keeps all the DLL's in a certain directory and all other programs refference those DLL's from that directory (Not current dir, Not System or System32 dir! i.e. C:\PROGRAM FILES\VENDOR\PROGRAM\MODULE1\MODULE.EXE reads LIBRARY1.DLL from C:\PROGRAM FILES\VENDOR\LIBRARIES\LIBRARY1.DLL)

How do you do this? At work we have our product that uses a couple of DLL's and currently the only way we have found to be sure that all programs have access to the DLL is to put a copy in each directory (I know it's a bad idea! But since my sup refuses to let us tell the clients to install the program on each workstation, instead just install it once and map a shared folder for everyone who uses the program) it's the best option we've found.

If someone has an idea, I'm all ears. BTW, it cannot be absolute path requirements unless you can also provide a way to obtain the absolute directory the program is run from.

Thanks!
-- Dan
0
Comment
Question by:DanEgli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6878800
search relative to your exe
Handle := LoadLibrary(Application.ExeName + '\mydlls\' +  MyDllName);

or add the dll path to the PATH env. variable.

Regards,
Steve




0
 
LVL 1

Author Comment

by:DanEgli
ID: 6878835
Oh... So then first question is what is handle? (handle := ??), next, is that static or dynamic loading? I'd prefer static loading (i.e. program starts up, and if it's missing a dll it says so and quits). Third. Since you are using a kind of Handle do I need to call procedure/functions like Handle.Foo(a,b,c); or is it just Foo(a,b,c);??

Thanks!
0
 
LVL 3

Accepted Solution

by:
SteveWaite earned 50 total points
ID: 6878975
the dynamic loading shown goes to any required directory
static loading

procedure DoSomething; external 'MYLIB.DLL';// dllpath
needs the path in there alrweady..

dynamic loading gives you the chance to set the path..

var
  dllpathv: String;
  dllHandle: THandle;
  MyFunc: function;

// e.g. in create
dllHandle := LoadLibrary(dllpath);
if not (dllHandle = 0)
  then @MyFunc := GetProcAddress(dllHandle, 'MydllFunc'); //etc.

// e.g. in destroy
if not (dllHandle = 0)
  then FreeLibrary(dllHandle);

Steve

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:SteveWaite
ID: 6878979
should say..
needs the path in there already..
and..
var
 dllpath: String;
0
 
LVL 1

Author Comment

by:DanEgli
ID: 6879099
so for a static load that would place the dll in, say, ..\libs\mylib.dll, calling procedure Foo, it would be like this?

procedure Foo(a,b,c : string) ; External '..\libs\mylib.dll';

This correct?

Thanks!
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6879203
Another possibility is to add it to the shared DLL's of the system. It is then found automatically, without the need to link it "hard" in the EXE file.

The following registry key holds the pasths to DLL's:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6889644
cheers dan
I think you will find the dll will get added automatically to the regkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs
after it's been used once.

Regards,
Steve
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 135
Dev Express grid collapse 2 52
Delphi: Connect to running MS Outlook 4 197
firemonkey Android Listview Sort items 7 97
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question