View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2941 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: 849 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: 2941 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 |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1269 Location: Morrison, CO, USA
|
Posted: Tue Sep 23, 2025 2:25 am Post subject: |
|
|
Similarly, one can use:
|
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2941 Location: South Pole, Antarctica
|
Posted: Sat Sep 27, 2025 6:08 am Post subject: |
|
|
Thanks Bill.
I tried it but unfortunately it does not work
AI gave me test program how to use it and it also does not work:
Code: |
PROGRAM GetProgramName
IMPLICIT NONE
CHARACTER(LEN=256) :: cmprognm@
CHARACTER(LEN=256) :: program_name
program_name = cmprognm@()
WRITE(*,*) 'The name of this program is: ', TRIM(program_name)
END PROGRAM GetProgramName |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8269 Location: Salford, UK
|
Posted: Sat Sep 27, 2025 6:56 am Post subject: |
|
|
It works for me. What goes wrong? |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2941 Location: South Pole, Antarctica
|
Posted: Sat Sep 27, 2025 9:40 am Post subject: |
|
|
This gives just the empty output. I am using WINE Windows emulation in Linux though. May be this is the reason. But so far I had very little and just the minor differences with true Windows, so I even do not remember what they were, this is probably the first one.
The code Ken provided works OK. |
|
Back to top |
|
 |
|