S
sbzldlb
Unregistered / Unconfirmed
GUEST, unregistred user!
function GetFileNameFromHandle(hFile:THandle):String;<br>Const<br> BUFSIZE=512;<br>Var<br> pszFilename:Array[0..BUFSIZE+1] of CHAR;<br> hFileMap:THandle;<br> //dwFileSizeHiWORD;<br> //dwFileSizeLoWORD;<br> pMemointer;<br> szTemp:Array[0..MAX_PATH-1] of CHAR;<br> pChar;<br> Str:String;<br>begin<br> Result:='';<br> FillChar(pszFilename,sizeof(pszFilename),0);<br> hFileMap := CreateFileMapping(hFile,<br> nil,<br> PAGE_READONLY,<br> 0,<br> 1,<br> nil);<br><br> if hFileMap<>INVALID_HANDLE_VALUE then<br> begin<br> pMem := MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 1);<br> if Assigned(pMem) then<br> begin<br> if GetMappedFileName (GetCurrentProcess,<br> pMem,<br> pszFilename,<br> MAX_PATH)<>0 then<br> begin<br> Str:=StrPas(pszFileName);<br> if GetLogicalDriveStrings(BUFSIZE-1, @pszFileName)<>0 then<br> begin<br> p:=@pszFileName;<br> Repeat<br> Inc(p,2);<br> p^:=#0;<br> Dec(p,2);<br> FillChar(szTemp,sizeof(szTemp),0);<br> if QueryDosDevice(p, @szTemp, MAX_PATH)<>0 then<br> begin<br> if AnsiPos(szTemp,Str)<>0 then<br> begin<br> Result := p+AnsiReplaceStr(Str,szTemp,'');<br> Exit;<br> end;<br> end;<br> Inc(p,4);<br> Until p^=#0;<br> end;<br> end;<br> UnmapViewOfFile(pMem);<br> end;<br> CloseHandle(hFileMap);<br> end;<br>end;