1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShlObj, ComObj, ActiveX, CommCtrl;
type PShellLinkInfoStruct = ^TShellLinkInfoStruct; TShellLinkInfoStruct = record FullPathAndNameOfLinkFile: array[0..MAX_PATH] of Char; FullPathAndNameOfFileToExecute: array[0..MAX_PATH] of Char; ParamStringsOfFileToExecute: array[0..MAX_PATH] of Char; FullPathAndNameOfWorkingDirectroy: array[0..MAX_PATH] of Char; Description: array[0..MAX_PATH] of Char; FullPathAndNameOfFileContiningIcon: array[0..MAX_PATH] of Char; IconIndex: Integer; HotKey: Word; ShowCommand: Integer; FindData: TWIN32FINDDATA; end;
TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure GetLinkInfo(lpShellLinkInfoStruct: PShellLinkInfoStruct); var ShellLink: IShellLink; PersistFile: IPersistFile; AnObj: IUnknown; begin AnObj := CreateComObject(CLSID_ShellLink); ShellLink := AnObj as IShellLink; PersistFile := AnObj as IPersistFile;
PersistFile.Load(PWChar(WideString(lpShellLinkInfoStruct^.FullPathAndNameOfLinkFile)), 0); with ShellLink do begin GetPath(lpShellLinkInfoStruct^.FullPathAndNameOfFileToExecute, SizeOf(lpShellLinkInfoStruct^.FullPathAndNameOfLinkFile), lpShellLinkInfoStruct^.FindData, SLGP_UNCPRIORITY);
GetDescription(lpShellLinkInfoStruct^.Description, SizeOf(lpShellLinkInfoStruct^.Description));
GetArguments(lpShellLinkInfoStruct^.ParamStringsOfFileToExecute, SizeOf(lpShellLinkInfoStruct^.ParamStringsOfFileToExecute));
GetWorkingDirectory(lpShellLinkInfoStruct^.FullPathAndNameOfWorkingDirectroy, SizeOf(lpShellLinkInfoStruct^.FullPathAndNameOfWorkingDirectroy));
GetIconLocation(lpShellLinkInfoStruct^.FullPathAndNameOfFileContiningIcon, SizeOf(lpShellLinkInfoStruct^.FullPathAndNameOfFileContiningIcon), lpShellLinkInfoStruct^.IconIndex);
GetHotKey(lpShellLinkInfoStruct^.HotKey);
GetShowCmd(lpShellLinkInfoStruct^.ShowCommand); end; end;
procedure TForm1.Button1Click(Sender: TObject); const br = #13#10; var LinkInfo: TShellLinkInfoStruct; s: string;
begin Memo1.Clear; FillChar(LinkInfo, SizeOf(LinkInfo), #0); StrLCopy(LinkInfo.FullPathAndNameOfLinkFile, PChar(Edit1.text), 255);
GetLinkInfo(@LinkInfo); with LinkInfo do s := FullPathAndNameOfLinkFile + br + FullPathAndNameOfFileToExecute + br + ParamStringsOfFileToExecute + br + FullPathAndNameOfWorkingDirectroy + br + Description + br + FullPathAndNameOfFileContiningIcon + br + IntToStr(IconIndex) + br + IntToStr(LoByte(HotKey)) + br + IntToStr(HiByte(HotKey)) + br + IntToStr(ShowCommand) + br + FindData.cFileName + br + FindData.cAlternateFileName; Memo1.Lines.Add(s); end;
end. |