如果是200分就好了:)<br><br>上次有人问了这个问题,从handle获得文件名,帖子忘记了,代码如下<br><br>uses uses psapi, StrUtils;<br><br><br>function GetFileNameFromHandle(hFile:THandle):String;<br>Const<br>BUFSIZE=512;<br>Var<br>pszFilename:Array[0..BUFSIZE+1] of CHAR;<br>hFileMap:THandle;<br>//dwFileSizeHi
WORD;<br>//dwFileSizeLo
WORD;<br>pMem
ointer;<br>szTemp:Array[0..MAX_PATH-1] of CHAR;<br>p
Char;<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&lt;&gt;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)&lt;&gt;0 then<br>begin<br>Str:=StrPas(pszFileName);<br>if GetLogicalDriveStrings(BUFSIZE-1, @pszFileName)&lt;&gt;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)&lt;&gt;0 then<br>begin<br>if AnsiPos(szTemp,Str)&lt;&gt;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;