View previous topic :: View next topic |
Author |
Message |
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Jan 26, 2016 6:30 pm Post subject: Using GETFULLPATHNAME Win 32 API |
|
|
I'm using the WIn32API call to determine the full (not relative) path name to a file. I have that working but ran across something I don't understand when trying to reconcile the MSDN description of the call and the implementation with FTN95.
Specifically, the FTN95 fourth parameter is specified as a 'REF'.
Quote: |
STDCALL GETFULLPATHNAME 'GetFullPathNameA' (STRING,VAL,STRING,REF &
&):INTEGER*4
|
The MSDN description of what should be there is:
Quote: | lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
|
I'm trying to understand what this REF actually returns relative to the description given in the MSDN Win 32 API descriptions.
Any ideas? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Tue Jan 26, 2016 7:56 pm Post subject: |
|
|
In C terms, the 3rd and 4th arguments are of type LPCSTR and LPCSTR *; the 3rd argument is an address that is known just before calling the Windows function. The fourth argument is the address of an address. The value of *lpFilePart is undefined/immaterial at entry, and Windows returns a pointer in lpFilePart. On the other hand, the value of the third argument must be set at entry and is not changed by the call. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Tue Jan 26, 2016 10:12 pm Post subject: |
|
|
... so it (Ipfilepart or REF) just tells where the file NAME starts ? so it can be retrieved seperately if needed I suppose ? |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Tue Jan 26, 2016 11:20 pm Post subject: |
|
|
You could just try:
INQUIRE (UNIT=LU5, NAME=INFILE)
With FTN95 this will return the full path name, although this does not with some other compilers. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Wed Jan 27, 2016 12:17 am Post subject: |
|
|
Thanks. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Jan 27, 2016 9:23 am Post subject: |
|
|
Code: | program myprog
stdcall GetFullPathName 'GetFullPathNameA'(string,val,string,ref):integer
integer r
character(256) buffer
r = GetFullPathName("myprog.exe",256,buffer,core4(0))
if(r > 0) print*, buffer(1:r)
end |
|
|
Back to top |
|
|
|