uses ComObj;
procedure CrnPinAppToWin7Taskbar(strPath, strApp: string);
var
vShell, vFolder, vFolderItem, vItemVerbs: Variant;
vPath, vApp: Variant;
i: Integer;
str, strPinName: String;
begin
vShell := CreateOleObject('Shell.Application');
vPath := strPath;
vFolder := vShell.NameSpace(vPath);
vApp := strApp;
vFolderItem := vFolder.ParseName(vApp);
vItemVerbs := vFolderItem.Verbs;
// 以下的PinName只适用于中文版的系统
// 英文版的系统要用'Pin to Tas&kbar'
// strPinName :='Pin to Tas&kbar';
strPinName :='锁定到任务栏(&K)';
for i :=1to vItemVerbs.Count do
begin
str := vItemVerbs.Item(i).Name;
if SameText(str, strPinName) then
begin
//63637275 6E 2E 63 6F 6D
vItemVerbs.Item(i).DoIt;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CrnPinAppToWin7Taskbar('C:\windows', 'regedit.exe');
end;
关键字词: