Created
May 23, 2022 04:01
-
-
Save ianfun/96ec5e62341f0a230900fdb34ccb40af to your computer and use it in GitHub Desktop.
Shell Notification Example in Win32 API
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 <windows.h> | |
#pragma comment (lib, "shell32.lib") | |
#pragma comment (lib, "User32.lib") | |
static UINT uID = 0; | |
void notifyUser() | |
{ | |
uID += 1; | |
{ | |
NOTIFYICONDATA n = NOTIFYICONDATA{.cbSize = sizeof(NOTIFYICONDATA), .uID = uID, .uFlags = NIF_ICON | NIF_TIP, .hIcon = LoadIcon(NULL, IDI_INFORMATION), .szTip="My Tips"}; | |
Shell_NotifyIcon(NIM_ADD, &n); | |
} | |
{ | |
NOTIFYICONDATA n = NOTIFYICONDATA{.cbSize = sizeof(NOTIFYICONDATA), .uID = uID, .uFlags = NIF_INFO, .szInfo="A Simple Notification Example", .uTimeout = 10000, .szInfoTitle="Hello", .dwInfoFlags = NIIF_INFO}; | |
Shell_NotifyIcon(NIM_MODIFY, &n); | |
} | |
} | |
int main(){ | |
notifyUser(); | |
notifyUser(); | |
notifyUser(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment