View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2939 Location: South Pole, Antarctica
|
Posted: Thu Sep 11, 2025 11:36 am Post subject: How to find the name of currently running EXE ? |
|
|
What function can supply the name of currently running program to this program?
I often run several instances of EXE at the same time and eventually become totally lost to find what is what. I may close some wrong program as a result. But if I will give EXE different names and display these names on running Clearwin window I will always know what is what
I know Clearwin command which supplies the path of the running code and display this path on top of each window, but this command does not supply the name of EXE
Opposite situation is with SDBG: it displays on the top the name of my EXE file which it is running but does not supply the path where is this EXE from. Would be good if it display the whole path too. For example now are running 5 programs under SDBG, each took hours to run and it is not easy to find what program is running under this or that open SDBG. Will also note, that the Command Prompt black window which SDBG opens at start has all the right path and the name of SDBG itself (showing that it is in the main FTN95 compiler directory). But what needed is that another SDBG window (where the debug actually happens) had display not just my code EXE name but the whole path with EXE name
Last edited by DanRRight on Thu Sep 11, 2025 12:09 pm; edited 1 time in total |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 840 Location: Lanarkshire, Scotland.
|
Posted: Thu Sep 11, 2025 12:08 pm Post subject: |
|
|
Dan, Does this help?
Code: |
program get_progname
use mswin
implicit none
integer(7) :: hModule
integer :: nChars
character(len=260) :: buffer
hModule = 0 ! 0 = current process
nChars = GetModuleFileName(hModule, buffer, len(buffer))
if (nChars > 0) then
print *, 'Running program is: ', trim(buffer(:nChars))
else
print *, 'Could not get program name.'
end if
end program |
|
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2939 Location: South Pole, Antarctica
|
Posted: Thu Sep 11, 2025 12:12 pm Post subject: |
|
|
Thanks you Ken, that exactly what was needed |
|
Back to top |
|
 |
|