タスクバーとスタートボタンの表示と非表示を切り替えるプログラムです。
Windows XPまではスタートボタンはタスクバーの中にあったため、タスクバーを非表示にしたらスタートボタンも消えていましたが、Windows Vista以降では、スタートボタンはタスクバーの中ではなくデスクトップに移動していたため、別途処理してやる必要があります。
尚、スタートボタンを消していてもキーボードのWindowsボタンからスタートメニューを表示することはできるため、それも非表示にしたい場合は"DV2ControlHost"も非表示にします。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// タスクバーとスタートボタンの表示と非表示を切り替えるプログラム | |
#include "stdafx.h" | |
#include <windows.h> | |
#include <tchar.h> | |
int main() | |
{ | |
// ClassName and WindowName | |
LPCTSTR name[][2] = { | |
{ _T("Shell_TrayWnd"), NULL },// Taskbar | |
{ _T("Button"), NULL },// Start Button | |
//{ _T("DV2ControlHost"), NULL}// Start Menu | |
}; | |
BOOL currentState = FALSE; | |
for (int i = 0; i < sizeof(name) / sizeof(name[0]); i++) { | |
HWND hWnd = FindWindow(name[i][0], name[i][1]); | |
if (i == 0) { | |
currentState = IsWindowVisible(hWnd);// Taskbar State | |
} | |
ShowWindow(hWnd, (currentState == FALSE ? SW_SHOW : SW_HIDE) ); | |
} | |
return 0; | |
} |