Path to dll file (not exe)

Windows specific forum
QuickFix
New User
New User
Posts: 3
Joined: Tue Jun 23, 2009 5:25 pm

Path to dll file (not exe)

Post by QuickFix »

Hi, after using PB for a while iv gotten fairly used to it and with help held within the forums and support sites iv always managed to achieve the task in hand without making any posts ... until now

I am writing a dll plug-in for another application and iv hit a situation where I need to retrieve the full path to the dll file as its called from the host application, all information i can find points to various ways of retrieving the path to the exe that called the dll but nothing to retrieve the actual path of the dll file.

I really hope someone can point me in the right direction
QuickFix
New User
New User
Posts: 3
Joined: Tue Jun 23, 2009 5:25 pm

Post by QuickFix »

never mind, i figured it out in the end.

Code: Select all

Procedure.s GetPluginPath()

  Protected Result.s
  Protected *Buffer=AllocateMemory(255)
  If *Buffer 
    GetModuleFileName_(GetModuleHandle_("APT.lmd"), *Buffer, 255)
    Result=GetPathPart(PeekS(*Buffer))
    FreeMemory(*Buffer)
  EndIf
    
  ProcedureReturn Result
  
EndProcedure



MessageRequester("",GetPluginPath())
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

If you want to know your path from within your DLL, you can use ProgramFilename(). I tried this in the past and it worked.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
QuickFix
New User
New User
Posts: 3
Joined: Tue Jun 23, 2009 5:25 pm

Post by QuickFix »

ah man, that's so much better, thanks

guess i was so busy searching for a api method i missed the obvious
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Yeah, you are right.
But I didn't understand your first post, so I didn't know if you are the DLL or the host process that wants to know the DLL-path. But it seems that you are the DLL. :)
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply