Page 1 of 1

Path to dll file (not exe)

Posted: Tue Jun 23, 2009 5:34 pm
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

Posted: Tue Jun 23, 2009 9:02 pm
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())

Posted: Tue Jun 23, 2009 9:52 pm
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.

Posted: Tue Jun 23, 2009 10:55 pm
by QuickFix
ah man, that's so much better, thanks

guess i was so busy searching for a api method i missed the obvious

Posted: Wed Jun 24, 2009 12:14 am
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. :)