如何正确得到.scr文件名的有趣问题(100分)

  • 主题发起人 coverworld
  • 开始时间
C

coverworld

Unregistered / Unconfirmed
GUEST, unregistred user!
.scr文件(屏保文件扩展名)当为长文件名的时候(如"scr name test.scr"),
在直接运行这个文件时能正确得到Application.ExeName为"scr name test.scr",但在windows的屏保设置窗口里设置为默认屏保运行时却无法得到它的完整文件名,只能返回"scrnam~1.scr",请问有什么方法可以得到其真正的文件名"scr name test.scr"

另一个有趣的问题是:在win98下好像是能得到正确文件名的,而在win2000/xp下却只能得到"scrname~1.scr"7.3格式的文件名,无论用paramstr(0)还是GetModulFilename()都一样。
 
uses
...,shellapi;
Function GetLongFileName(Const FileName : String) : String;

var
aInfo: TSHFileInfo;

begin

if SHGetFileInfo(PChar(FileName),0,aInfo,Sizeof(aInfo),SHGFI_DISPLAYNAME)<>0 then

Result:= String(aInfo.szDisplayName)
else

Result:= FileName;

end;
调用:
edit1.text:=GetLongFileName('C:/PCCF-0~1.DAT');
 
接受答案了.
 
顶部