Skip to content

Instantly share code, notes, and snippets.

@ianfun
Created May 23, 2022 04:01
Show Gist options
  • Save ianfun/96ec5e62341f0a230900fdb34ccb40af to your computer and use it in GitHub Desktop.
Save ianfun/96ec5e62341f0a230900fdb34ccb40af to your computer and use it in GitHub Desktop.
Shell Notification Example in Win32 API
#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