Program Name...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jeslar360
User
User
Posts: 20
Joined: Thu Aug 28, 2008 6:24 am

Program Name...

Post 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
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

:?:

Code: Select all

Debug ProgramFilename()
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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 :-))
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post 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. 
jeslar360
User
User
Posts: 20
Joined: Thu Aug 28, 2008 6:24 am

Post 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 :)
Post Reply