Folks,
Get the program and command line of a shortcurt file (.LNK)
| Delphi | | copy code | | ? |
| 01 | uses ActiveX, ComObj, ShlObj; |
| 02 | |
| 03 | function GetShortcutCmd(AShortcutPath: string): string; |
| 04 | var |
| 05 | ShellLink: IUnknown; |
| 06 | Win32Data: TWin32FindData; |
| 07 | Buff: array [0..MAX_PATH*2] of Char; |
| 08 | begin |
| 09 | ShellLink := CreateComObject(CLSID_ShellLink); |
| 10 | with (ShellLink as IShellLink), (ShellLink as IPersistFile) do |
| 11 | begin |
| 12 | Load(PWChar(WideString(AShortcutPath)), 0); |
| 13 | GetPath(@Buff[0], MAX_PATH, Win32Data, SLGP_UNCPRIORITY); |
| 14 | GetArguments(@Buff[MAX_PATH], MAX_PATH); |
| 15 | Result := Trim(PChar(@Buff) + ' ' + PChar(@Buff[MAX_PATH])); |
| 16 | end; |
| 17 | end; |
Tags: CLSID_ShellLink, Delphi, GetShortcutCmd, IPersistFile, IShellLink, SLGP_UNCPRIORITY, TWin32FindData, Usefull Function
