On the csdn forum, I saw some netizens asking how to pin the program to the Windows 7 taskbar. ccrun (demon brother) was very interested in this issue. So I googled it and did not find relevant API materials, however, you can see the method implemented using the folderitemverb object on a foreign site. For details, refer to msdn:
Http://msdn.microsoft.com/en-us/library/windows/desktop/bb774172 (V = vs.85). aspx
The Code implemented in Delphi is as follows. Compiling environment: Delphi7 and xe2. The test operating system is Windows 7 in Chinese and English.
uses ComObj;procedure CrnPinAppToWin7Taskbar(strPath, strApp: string);var vShell, vFolder, vFolderItem, vItemVerbs: Variant; vPath, vApp: Variant; i: Integer; str: String; h: HINST; szPinName: array[0..255] of Char;begin vShell := CreateOleObject('Shell.Application'); vPath := strPath; vFolder := vShell.NameSpace(vPath); vApp := strApp; vFolderItem := vFolder.ParseName(vApp); vItemVerbs := vFolderItem.Verbs; h := LoadLibrary('Shell32.dll'); LoadString(h, 5386, szPinName, 256); FreeLibrary(h); for i := 1 to vItemVerbs.Count do begin str := vItemVerbs.Item(i).Name; if SameText(str, szPinName) then begin // 63 63 72 75 6E 2E 63 6F 6D vItemVerbs.Item(i).DoIt; end; end;end;procedure TForm1.Button1Click(Sender: TObject);begin CrnPinAppToWin7Taskbar('C:\windows', 'regedit.exe');end;
In addition, thanks to titilima, it is easier to pin the. lnk file to the win7 taskbar:
ShellExecute(nil, 'TaskbarPin', 'E:\Temp\Notepad.lnk'), nil, nil, SW_SHOW);
This article from: http://blog.csdn.net/ccrun/article/details/6906471