DECLARE INTEGER GetFullPathName IN WIN32API ; > STRING @ LPCTSRSHORTNAME, ; > STRING @ LPTSRFULLNAME, ; > INTEGER cbBuffer >cFullName = REPL(chr(0), 262) >nBufLen = 261 >IF GetFullPathName('Short\path\name'+CHR(0),@cFullName,nBufLen) # 0 > cFullName = STRTRAN(cFullName,CHR(0),'') >ELSE > && retrieve error using GetLastError() >ENDIF>
DECLARE INTEGER GetFullPathName IN WIN32API ; STRING @ lpFileName, ; INTEGER dwBufferLen, ; STRING @ lpBuffer, ; INTEGER lpFileName cFullName = REPL(chr(0), 262) nBufLen = 261 lpFileName = 0 IF GetFullPathName('FileName', nBufLen, @cFullName, @lpFileName) > 0lpFileName will be invalid unless you allocate a static buffer outside the VFP memory space using a tool like ClsHeap, since the buffer result will be moved on return from the function call if it points to a VFP string. If you use ClsHeap, allocate a buffer of 261 characters, change the definition of lpBuffer to INTEGER rather than STRING @, pass the address of the buffer to the function and use the CopyFrom() method or the GetMemString() UDF to move the result back to VFP string space.