您的位置:首页 > 编程语言 > Delphi

【收藏】创建桌面快捷键的程序(delphi)

2007-08-14 11:09 756 查看

Delphi 7:






{ Function: create a desktop shortcut to your application }




{ make sure you add these units in the uses clause. }




uses ShellAPI, ComObj, ComCtrls, Shlobj, ActiveX;






procedure CreateShortCut;


var


psl : IShellLink;


ppf : IPersistFile;


ws : WideString;


wss : array[0..MAX_PATH] of AnsiChar;




begin


psl := CreateComObject(CLSID_ShellLink) as IShellLink;


ppf := psl as IPersistFile;


if Assigned( psl ) then


try


psl.SetPath( PChar( ParamStr( 0 ) ) );


psl.SetWorkingDirectory( PChar( ExtractFilePath( Application.ExeName ) ) );


psl.SetShowCmd( SW_SHOWNORMAL );


psl.SetDescription( PChar( 'Your app name' ) );


GetEnvironmentVariable( PChar('USERPROFILE'), wss, sizeof(wss) - 1 );


ws := wss + 'DesktopYour app name.lnk';


ppf.Save( PWChar( ws ), False );


finally


end;


end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: