如何获取任务栏句柄~~

 本文将介绍一个未公开的Win32 API函数:GetTaskmanWindow,利用它对Windows的任务栏进行操作。这个函数返回拥有任务栏按钮的窗口句柄。在微软的MSDN文档中,对任务栏是这样描述的:"……Windows界面包含一个特殊的应用程序桌面工具栏,叫做任务栏。任务栏可以用于在打开的不同窗口之间进行切换,以及启动新的应用程序……。任务栏包含有开始菜单、任务栏按钮、快捷菜单和状态显示区……"。可惜在Win32 API的正式问当中没有能存取任务栏的函数。因此我们必须使用未公开的Win32 API函数。
下面是GetTaskmanWindow的原型:

 

// getaskmanwnd.cpp (Windows NT/2000)
//
// This example will show you how you can obtain a handle to the
// Windows Taskbar window.
//
// (c)1999 Ashot Oganesyan K, SmartLine, Inc
// mailto:ashot@aha.ru, http://www.protect-me.com, http://www.codepile.com

#include <windows.h>
#include <stdio.h>


// User32!GetTaskmanWindow (NT specific!)
//
// This function returns a handle to the window that ownes the taskbar buttons
//
// HWND GetTaskmanWindow()
//
typedef HWND (WINAPI *PROCGETTASKMANWND)(void);


PROCGETTASKMANWND GetTaskmanWindow;


void main(int argc, char* argv[])
{
  if (argc<2)
  {
     printf("Usage:/n/ngetaskmanwnd.exe S|H/n");
     return;
  }

  HMODULE hUser32 = GetModuleHandle("user32");
  if (!hUser32)
      return;

  GetTaskmanWindow = (PROCGETTASKMANWND)GetProcAddress(hUser32,"GetTaskmanWindow");
  if (!GetTaskmanWindow)
      return;

  HWND hWnd = GetTaskmanWindow();

  if (!hWnd)
      return;

  if (*argv[1]=='H' || *argv[1]=='h')
      ShowWindow(GetParent(hWnd),SW_HIDE);
  else
      ShowWindow(GetParent(hWnd),SW_SHOW);
 
}

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值