C++ C++;系统托盘中的shellapi显示图标
我现在的代码:C++ C++;系统托盘中的shellapi显示图标,c++,C++,我现在的代码: #include <windows.h> #include <shellapi.h> #include <commctrl.h> #include <iostream> const int LIM_SMALL = 0x000000b; using namespace std; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCm
#include <windows.h>
#include <shellapi.h>
#include <commctrl.h>
#include <iostream>
const int LIM_SMALL = 0x000000b;
using namespace std;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
NOTIFYICONDATA nid;
nid.cbSize = sizeof(nid);
nid.hWnd = GetActiveWindow();
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
nid.uID = (unsigned long int) 0x161BE1FA;
//I'll write a function to do that properly later
nid.szTip[0] = 't';
nid.szTip[1] = 'e';
nid.szTip[2] = 's';
nid.szTip[3] = 't';
nid.uCallbackMessage;
//Those are the same thing but "LoadIconMetric" can automaticly scale the icons to the needed size
nid.hIcon = LoadIcon(NULL, IDI_INFORMATION);
//HRESULT hr = LoadIconMetric(NULL, "Net_switch_wifi32.ico", LIM_SMALL, &(nid.hIcon));
Shell_NotifyIcon(NIM_ADD, &nid) ? S_OK : E_FAIL;
cout << nid.uID << endl;
cin.get();
Shell_NotifyIcon(NIM_DELETE, &nid) ? S_OK : E_FAIL;
return 0;
};
#包括
#包括
#包括
#包括
const int LIM_SMALL=0x000000b;
使用名称空间std;
int APIENTRY WinMain(HINSTANCE HINSTANCE、HINSTANCE hPrevInstance、LPSTR lpCmdLine、int nShowCmd){
国家信息中心;
nid.cbSize=sizeof(nid);
nid.hWnd=GetActiveWindow();
nid.uFlags=NIF_图标| NIF_消息| NIF_提示;
nid.uID=(无符号长整型)0x161BE1FA;
//稍后我将编写一个函数来正确地执行此操作
nid.szTip[0]=“t”;
nid.szTip[1]=“e”;
nid.szTip[2]=“s”;
nid.szTip[3]='t';
nid.uCallbackMessage;
//这些都是相同的东西,但“LoadIconMetric”可以自动将图标缩放到所需的大小
nid.hIcon=加载图标(空,IDI_信息);
//HRESULT hr=LoadIconMetric(NULL,“Net_switch_wifi32.ico”、LIM_SMALL和(nid.hIcon));
Shell\u NotifyIcon(NIM\u添加和nid)?S\u确定:E\u失败;
库特