Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 7 - Taskbar - Pin or Unpin Program Links

As in title, is there any Win32 API to do that?

like image 474
Yigang Wu Avatar asked Dec 28 '09 05:12

Yigang Wu


2 Answers

Don't do this.

I'm 99% sure there isn't an official API for it, for exactly the same reason that there wasn't programmatic access to the old Start Menu's pin list.

In short, most users don't want programs putting junk in their favorites, quick launch, taskbar, etc. so Windows doesn't support you doing as such.

like image 91
Kevin Montrose Avatar answered Oct 10 '22 08:10

Kevin Montrose


I'm trying to implement a VirtuaWin (opensource virtual desktop software) plugin that allows me to pin different buttons to different virtual desktops. Completely valid reason to use this.

Found the way to pin/unpin it already:

Following code snippet is taken from Chromium shortcut.cc file, nearly unchanged, see also the ShellExecute function at the MSDN

bool TaskbarPinShortcutLink(const wchar_t* shortcut) {
  int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarpin", shortcut,
      NULL, NULL, 0));
  return result > 32;
}

bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) {
  int result = reinterpret_cast<int>(ShellExecute(NULL, L"taskbarunpin",
      shortcut, NULL, NULL, 0));
  return result > 32;
}    
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Seems pretty straightforward if you know the shortcut. For me though this is not sufficient, I also need to iterate over existing buttons and unpin and repin them on different desktops.

like image 25
Ciantic Avatar answered Oct 10 '22 06:10

Ciantic