清空回收站内文件
#include<windows.h>
#include<WinUser.h>
int main()
{
SHEmptyRecycleBin(NULL,NULL,NULL);
}
原理:SHEmptyRecycleBin()函数原型
SHEmptyRecycleBin(
HWND hwnd,
LPCTSTR pszRootPath,
DWORD dwFlags);
注意:dwFlags 表示选项,例如: SHERB_NOCONFIRMATION 不显示确认删除对话框 SHERB_NOSOUND 删除完成后不播放声音
例如:
#include<windows.h>
#include<WinUser.h>
int main()
{
SHEmptyRecycleBin(NULL,NULL,SHERB_NOCONFIRMATION);
}
执行后没有确认删除对话框。
隐藏和显示桌面图标
隐藏桌面图标
#include<windows.h>
#include<WinUser.h>
int main()
{
HWND hDeskWnd=::FindWindow("Progman",NULL);
ShowWindow(hDeskWnd,SW_HIDE);
}
运行后如下图:
显示桌面图标
#include<windows.h>
#include<WinUser.h>
int main()
{
HWND hDeskWnd=::FindWindow("Progman",NULL);
ShowWindow(hDeskWnd,SW_SHOW);
}
注意: ::FindWindow(“Progman”,NULL); 为获取桌面窗体句柄。
隐藏和显示 Windows 任务栏
隐藏任务栏
#include<windows.h>
int main()
{
HWND hWinBar = ::FindWindow("Shell_TrayWnd","");
:: ShowWindow(hWinBar,SW_HIDE);
}
运行后如下图:
显示任务栏
#include<windows.h>
int main()
{
HWND hWinBar = ::FindWindow("Shell_TrayWnd","");
:: ShowWindow(hWinBar,SW_SHOW);
}
隐藏和显示任务栏时钟
隐藏任务栏时钟
#include<windows.h>
int main()
{
HWND hWinBar= :: FindWindow("Shell_TrayWnd",NULL);
HWND hNotifyWnd = :: FindWindowEx(hWinBar,0,"TrayNotifyWnd",NULL);
HWND hClockWnd = :: FindWindowEx(hNotifyWnd,0,"TrayClockWClass",NULL);
::ShowWindow(hClockWnd,SW_HIDE);
}
运行后如下图:
显示任务栏时钟
#include<windows.h>
int main()
{
HWND hWinBar= :: FindWindow("Shell_TrayWnd",NULL);
HWND hNotifyWnd = :: FindWindowEx(hWinBar,0,"TrayNotifyWnd",NULL);
HWND hClockWnd = :: FindWindowEx(hNotifyWnd,0,"TrayClockWClass",NULL);
::ShowWindow(hClockWnd,SW_SHOW);
}
更改桌面壁纸
#include<windows.h>
#include<bits/stdc++.h>
int main()
{
SystemParametersInfo (SPI_SETDESKWALLPAPER, 0 , (void*)"C:\\Untitled.png" , 0);
}
注意: (void*) 后面是你要更换的壁纸的路径,用双重反斜杠 \\ !
|