1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| function TForm4.CreateLink(lpszPathobj, lpszPathLink, lpszDesc: String): Boolean; var psl: IShellLink; ppf: IPersistFile; wsz: PWideChar; begin Result := false; if SUCCEEDED(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, psl)) then begin psl.SetPath(PChar(lpszPathObj)); psl.SetDescription(PChar(lpszDesc)); if SUCCEEDED(psl.QueryInterface(IID_IPersistFile, ppf)) then begin GetMem(wsz, MAX_PATH * 2); try MultiBytetoWideChar(CP_ACP, 0, PChar(lpszPathLink), - 1, wsz, MAX_PATH); ppf.Save(wsz, true); Result := true; finally FreeMem(wsz, MAX_PATH * 2); end; end; end; end; |