How to pin a program to the Windows 7 taskbar (revised version)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.