Site hosted by Angelfire.com: Build your free website today!

OLE-COM ( Tech Hint Delphi )


Precedente Home Su Successiva

 

 

WinNT services
System Menu (Tech hint)
OLE-COM ( Tech Hint Delphi )
Misc (Tech Hint Delphi)

 

 

 

 

Using OLE/COM technology with Delphi programming tool (Last update: 19-01-2003 )

Create a link to a file using IShellLink

Get the file pointed by its link name

 

Create a link to a file using IShellLink         (Go to index)

procedure CreateLink ( FileName, LinkName: string );
var
aBuffer: array[0..200] of char;
wBuffer: WideString;
shlLink: IShellLink;
persFile: IPersistFile;
res: HResult;
begin
shlLink := CreateComObject( CLSID_SHellLink ) as IShellLink;
persFile := shlLink as IPersistFile;
strpCopy( aBuffer, FileName);
res := shlLink.setPath( aBuffer );
wBuffer := LinkName + '.lnk';
res := persFile.save( pwChar(wBuffer), true );

end;

Go to index

Get the file pointed by its link name              (Go to index)

str1 := 'Resolving link: ' + wBuffer + ' --> ' + ResolveTheLink( myLinkName);
messageDlg( str1, mtInformation, [mbOK], 0 );

function ResolveTheLink( LinkName: string ): string;
var
aBuffer: array[0..200] of char;
wBuffer: WideString;
shlLink: IShellLink;
persFile: IPersistFile;
win32FindData: Twin32FindData;
res: HResult;
begin
shlLink := CreateComObject( CLSID_SHellLink ) as IShellLink;
persFile := shlLink as IPersistFile;
wBuffer := EditLnkName.text + '.lnk';
res := persFile.load( pwChar(wBuffer), STGM_READ );
res := shlLink.getPath( aBuffer, 200, win32FindData, 0 );
result := strPas(aBuffer);
end;

Go to index

 

 

 

 

   if you have some suggestion or question about this program please mail me at enzo.arlati@libero.it

Main index 
NEWS

 

Last update:   19-01-2003

Hosted by :  
Xoom