I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This     

Where is my dll located?

Where is my dll located? in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: located   Where my   Where my dll  
smw
 (Inactive)
-- USA
I have a delphi dll, and I need to be able find the directory where the dll is located. Application.ExeName returns the location of the application calling the dll, but I need to know the location of the actual dll (it is not the same place as the calling application and not in the System directory). Is there a way to do this?? It seems such a simple thing but I am new to delphi and not sure how to do it.
 Posted 17 years ago (Thread Starter)
Comment Quote
About smw -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9133, 5 replies
Thread Started 2/27/2003 8:33:00 PM
View Counter=2825
Last Reply Posted 3/4/2003 7:07:00 PM)
Location=-- USA 
Joined=18 years ago   MB Posts=4  
rt
Castel, -- UK
Is this too simple? Just type the name of the missing .dll into the Windows file finder thing and see what it doth bring up?

Thats enough of that. Ed.

 Posted 17 years ago
Comment Quote
About rt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About rt

I do like my jazz and blues!


Post ID #9134 (Level 1.1)  Reply to 9133
Thread Started 2/28/2003 1:24:00 AM
View Counter=2
Location=Castel, -- UK 
Joined=20 years ago   MB Posts=687   KB Comments=1  
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
Let me guess...you found it in \Program Files\Borland\Delphi 6\Projects\Bpl (or Delphi 5, or whatever version you're using...).

This trips people up at first, but you'll find that there are two things Delphi is doing here:


  • 1. The folder \Program Files\Borland\Delphi #\Projects\Bpl is in your PATH environment
  • 2. This is the default directory where Delphi puts libraries.



Delphi does task 1. on installation. Since I release a lot of libraries to customers, I took that directory out of my path (so I could catch the kind of problem you're experiencing).


As for 2., look in the Delphi IDE in Tools/Environment Options and look at the Library tab. If the BPL output directory setting is blank, then this is where Delphi is sticking your DLL by default for new library projects.



The simple fix is to always make sure that you have this set to a common folder in your PATH where you want to find DLL's. Why fish around under \Program Files\ for your builds each time? I use C:\Bin for my default BPL output directory (which makes it easy to create InstallShield projects too). And, since I compose a lot of DLL's, using C:\Bin makes it super-easy to find an executable DLL, rather than combing through the world of the Windows\System32 folder! Now that

When you compose a library project, the Project Options has the same settings on the Directories/Conditionals tab. Make a habit of always specifying an output directory...even if it's something as simple as .\Output (i.e. subfolder off of the current project folder).
 Posted 17 years ago
Comment Quote
About Scott Wehrly -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9140 (Level 1.2)  Reply to 9133
Reply Posted 2/28/2003 12:26:00 PM
Location=Las Vegas, NV USA 
Joined=18 years ago   MB Posts=442   KB Posts=19  
Larry Drews
Iowa
The DLL has its own Application object. That Application object has a property, Application.Handle which is the Windows module handle for the DLL.

Use
GetModuleFileName (Application.Handle,Path,Pathsize) to get the path of the DLL. You have to provide a buffer for Path and specify the maximum Pathsize. The path will be stored as a pchar type string in Path.

Check out the Win32 help on GetModuleFileName for details.

Hope this helps.
 Posted 17 years ago
Comment Quote
About Larry Drews -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Larry Drews
Veteran software developer specializing in Delphi/Kylix development. Currently Manager of Applications Development for a biotech company in Iowa.

Post ID #9176 (Level 1.3)  Reply to 9133
Reply Posted 3/4/2003 4:50:00 PM
Location=Iowa  
Joined=18 years ago   MB Posts=67   KB Comments=1  
smw
 (Inactive)
-- USA
Maybe a little confusion here. I have written the dll in delphi and within the dll code I need to dll itself to find out where it is installed. I.e. if a dll is installed at c:\program files\someApplication\ and the dll is being called from somewhere else, I need the dll itself to know that it is located in c:\program files\someApplication\.

I realise it may not make sense why I want do this... welcome to the world of legacy code!!
 Posted 17 years ago (Thread Starter)
Comment Quote
About smw -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9173 (Level 1.4)  Reply to 9133
Reply Posted 3/4/2003 3:04:00 PM
Location=-- USA 
Joined=18 years ago   MB Posts=4  
Most Recent Post
smw
 (Inactive)
-- USA
Thanks for that. Such a simple answer in the end and i have been trying to figure this out for a long time. I ended up just writing the following function to return the location of the dll being used.

function GetModuleFileSpec: String;
var
cret: integer;
test: string;
ModName: array[0..MAX_PATH - 1] of Char;
begin
Windows.GetModuleFileName(HInstance, ModName, SizeOf(ModName));
GetModuleFileSpec := ModName;

end;
 Posted 17 years ago (Thread Starter)
Comment Quote
About smw -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9177 (Level 1.5)  Reply to 9133
Reply Posted 3/4/2003 7:07:00 PM
Location=-- USA 
Joined=18 years ago   MB Posts=4  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1216A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #9133 Counter
2825
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech