- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Forum members,
Sometimes the calling sequence GETARG(0,BUFFER) just gives me the file name of the program running (as it should be, according to the manual); but many times it returns the whole path (e.g. "C:MYFOLDERYOURFOLDERHERFOLDERHISPROGRAM.EXE"). I have two questions about this behaviour:
1) In what conditions will the whole path be returned by the calling sequence?
2) Is there any method (apart from using assembly language and learning about the entrails of Windows) to always getting the whole path?
I am using Intel VF 9.1 on WindowsXP Professional.
Yours sincerely,
Niels H. Veldhuijzen
Cito, Arnhem, The Netherlands
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know why you see different values - it may have to do with how the program was invoked. But the following always works:
use kernel32
implicit none
integer(HANDLE) :: self
character(MAX_PATH) :: path
integer :: pathlen
! Get handle to self
self = GetModuleHandle(NULL)
! Get path of self
pathlen = GetModuleFileName (self, path, len(path))
! Display path
write (*,*) "Hi, I'm ", path(1:pathlen)
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve (and all),
Thank you very much. I see I have to refresh my memory on APIs. Actually, the manual says that GETARG(0,BUFFER) gives you the first thing there is on the command line. Usually this is the program name. But, of course, many times you don't see any command line; e.g. when you activate a program by clicking its name in the file selector. As, in our application,it is of paramount importance to get the name of the folder the program is residing in, your API workaround is wonderful!
Yours sincerely,
Niels H. Veldhuijzen, Arnhem, The Netherlands
![](/skins/images/2E08A100FB92911314A240D1EAFB2828/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page