主题:请问如何在程序中创建快捷键
jiankw
[专家分:0] 发布于 2006-05-12 16:19:00
我的一个程序需要,而自己以前学习时又没好好学!现在请各位高手帮帮忙!
回复列表 (共2个回复)
沙发
zaliang [专家分:1010] 发布于 2006-05-12 17:28:00
shortcut好像有这个属性吧??
板凳
guo888go2005 [专家分:150] 发布于 2006-05-13 16:48:00
function CreateLink(filepath: string; linkName: string): boolean; //
var
tmpObject: IUnknown;
tmpSLink: IShellLink;
tmpPFile: IPersistFile;
PIDL: PItemIDList;
StartupDirectory: array[0..MAX_PATH] of Char;
StartupFilename: string;
LinkFilename: WideString;
begin
StartupFilename := filepath;
tmpObject := CreateComObject(CLSID_ShellLink); //创建建立快捷方式的外壳扩展
tmpSLink := tmpObject as IShellLink; //取得接口
tmpPFile := tmpObject as IPersistFile; //用来储存*.lnk文件的接口
tmpSLink.SetPath(pChar(StartupFilename)); //设定notepad.exe所在路径
tmpSLink.SetWorkingDirectory(pChar(ExtractFilePath(StartupFilename))); //设定工作目录
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL); //获得桌面的Itemidlist
SHGetPathFromIDList(PIDL, StartupDirectory); //获得桌面路径
LinkName := '\' + 'MyNotepad.lnk';
LinkFilename := StartupDirectory + linkName;
tmpPFile.Save(pWChar(LinkFilename), FALSE); //保存*.lnk文件
end;
我来回复