Silverfrost Forums

Welcome to our forums

Using GETFULLPATHNAME Win 32 API

26 Jan 2016 5:30 #17164

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'.

  STDCALL GETFULLPATHNAME 'GetFullPathNameA' (STRING,VAL,STRING,REF &
 &):INTEGER*4

The MSDN description of what should be there is:

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?

26 Jan 2016 6:56 #17165

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.

26 Jan 2016 10:20 #17167

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.

26 Jan 2016 11:17 #17168

Thanks.

27 Jan 2016 8:23 #17170
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
Please login to reply.