If you use ProgramFilename() as a call from a .dll, the .dll and it's directory are the output.
For instance if the program is Test.exe and the .dll in it has the name display.dll, then if a function in the .dll calls ProgramFilename() from within the Test.exe, the output will show display.dll
C:\display.dll
I need it to display the name of the .exe
C:\Test.exe
Is there a call or command that shows the name and path of the running program, even if the command is called from within a .dll of that program?
Is there quick windows api hack for this? NameOfRunningProgam() !???
Get ProgramFilename() info for the .exe, not .dll
-
- Enthusiast
- Posts: 118
- Joined: Thu May 17, 2007 8:35 pm
- Location: USA
-
- Enthusiast
- Posts: 118
- Joined: Thu May 17, 2007 8:35 pm
- Location: USA
Re: Get ProgramFilename() info for the .exe, not .dll
Another way to ask this, is there a command that can be called from within a .dll to give the path and name of the .exe that the .dll is currently being used in?
Re: Get ProgramFilename() info for the .exe, not .dll
Hi Mike Yurgalavage,
Windows Services & Other Stuff
- \Other_Stuff\ProcessStuff\CallingProcess\...
Run the executable and the DLL will report the calling process (path \ executable).
Windows Services & Other Stuff
- \Other_Stuff\ProcessStuff\CallingProcess\...
Run the executable and the DLL will report the calling process (path \ executable).
-
- Enthusiast
- Posts: 118
- Joined: Thu May 17, 2007 8:35 pm
- Location: USA
Re: Get ProgramFilename() info for the .exe, not .dll
Thanks for reply, got it sorted!JHPJHP wrote:Hi Mike Yurgalavage,
Windows Services & Other Stuff
- \Other_Stuff\ProcessStuff\CallingProcess\...
Run the executable and the DLL will report the calling process (path \ executable).
For those interested,
Code: Select all
;-GRAB EXE NAME AND DIRECTORY
;{
OpenWindow(1,-1000,-1000,0,0,"")
buffer.s{512}
max.q = Len(buffer)-2
window_h.q
window_name.s
process_id.q
process_h.q
This_application_name.s
OpenLibrary(1,"kernel32.dll")
K32GetModuleFileNameExW_ = GetFunction(1,"K32GetModuleFileNameExW")
window_h = WindowID(1);GetForegroundWindow_()
If window_h <> 0
String_length.q = GetWindowText_(window_h,@buffer,max)
window_name = PeekS(@buffer,String_length)
GetWindowThreadProcessId_(window_h,@process_id)
If process_id <> 0
process_h = OpenProcess_(#PROCESS_QUERY_INFORMATION|#PROCESS_VM_READ , #False, process_id)
If process_h <> 0
String_length = CallFunctionFast(K32GetModuleFileNameExW_ ,process_h, 0, @buffer, max)
This_application_name = PeekS(@buffer,String_length)
EndIf
EndIf
EndIf
CloseLibrary(1)
CloseWindow(1)
Mike