var
vShellLink: IShellLink;
vPersistFile: IPersistFile;
vUnKnown: IUnKnown;
s,d:string;
ws:widestring;
pws:PWideChar;
ffd:WIN32_FIND_DATA;
ret:Longint;
begin
vUnKnown := CreateComObject(CLSID_ShellLink);
vShellLink := vUnKnown as IShellLink;
vPersistFile := vUnKnown as IPersistFile;
ws:=Edit1.Text ;
if vPersistFile.Load(PWideChar(ws),0) = S_OK then
begin
if vShellLink.Resolve(Self.Handle,SLR_ANY_MATCH ) =NOERROR then
begin
ret:=vShellLink.GetPath(Pchar(s),MAX_PATH,ffd,SLGP_SHORTPATH );
//这句老是运行时错误为什么啊?
if ret= NOERROR then
edit2.Text :=s;
end;
end;
end;
vShellLink: IShellLink;
vPersistFile: IPersistFile;
vUnKnown: IUnKnown;
s,d:string;
ws:widestring;
pws:PWideChar;
ffd:WIN32_FIND_DATA;
ret:Longint;
begin
vUnKnown := CreateComObject(CLSID_ShellLink);
vShellLink := vUnKnown as IShellLink;
vPersistFile := vUnKnown as IPersistFile;
ws:=Edit1.Text ;
if vPersistFile.Load(PWideChar(ws),0) = S_OK then
begin
if vShellLink.Resolve(Self.Handle,SLR_ANY_MATCH ) =NOERROR then
begin
ret:=vShellLink.GetPath(Pchar(s),MAX_PATH,ffd,SLGP_SHORTPATH );
//这句老是运行时错误为什么啊?
if ret= NOERROR then
edit2.Text :=s;
end;
end;
end;
http://dev.csdn.net/develop/article/10/10482.shtm
翻译一下就可以了!:)