Page 1 of 1

Program Name...

Posted: Thu Aug 28, 2008 6:46 am
by jeslar360
I want a native function that you can put into a library, (DLL, SO...) that will allow you to tell what program file opened/accessed it.

Much like this does, but cross platform...(Run this from a DLL, and it will return the path/filename of the program file that called it.)

Code: Select all

Procedure.s GetExeName()
  sApp.s=Space(256)
  GetModuleFileName_(GetModuleHandle_(0), @sApp, 256)
  ProcedureReturn sApp
EndProcedure

Posted: Thu Aug 28, 2008 6:59 am
by nco2k
:?:

Code: Select all

Debug ProgramFilename()
c ya,
nco2k

Posted: Thu Aug 28, 2008 10:19 am
by blueznl
nco2k, he's looking for something from something inside a DLL that identifies the calling program. Does ProgramFilename() work from within a DLL? (never tried, actually :-))

Posted: Thu Aug 28, 2008 11:50 pm
by luis
blueznl wrote: Does ProgramFilename() work from within a DLL? (never tried, actually :-))
from the docs

Code: Select all

If used inside a Dll, this function returns the path and filename of the dll, not the main program that loaded it. 

Posted: Fri Aug 29, 2008 5:15 am
by jeslar360
No, I already tried that function, and luis is right. Inside a DLL, only the DLLs name and path are returned. Whereas...the API call I did in my example, will get the path/name of the executable itself. I just want a way to do that native with PB, so that its cross platform :)