Windows 7 - Taskbar - Pin or Unpin Program Links

后端 未结 8 1516
不思量自难忘°
不思量自难忘° 2021-01-12 04:13

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

8条回答
  •  死守一世寂寞
    2021-01-12 04:36

    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(ShellExecute(NULL, L"taskbarpin", shortcut,
          NULL, NULL, 0));
      return result > 32;
    }
    
    bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) {
      int result = reinterpret_cast(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.

提交回复
热议问题