Skip to content

Instantly share code, notes, and snippets.

@ynkdir
Created September 3, 2014 15:47
Show Gist options
  • Save ynkdir/af96e73b7ab1cbf01032 to your computer and use it in GitHub Desktop.
Save ynkdir/af96e73b7ab1cbf01032 to your computer and use it in GitHub Desktop.
// > cl /LD set_icon.c user32.lib
// :call libcallnr('path/to/set_icon.dll', 'set_icon', v:windowid . ',' . 'path/to/myvim.ico')
#include <windows.h>
#include <stdio.h>
__declspec(dllexport) int set_icon(char **args)
{
HWND hWnd;
char iconpath[1024];
HICON hIcon;
if (sscanf(args, "%d,%s", &hWnd, &iconpath) != 2)
return -1;
hIcon = (HICON)LoadImage(NULL, iconpath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if (hIcon == NULL)
return -2;
SendMessage(hWnd, WM_SETICON, ICON_BIG, hIcon);
SendMessage(hWnd, WM_SETICON, ICON_SMALL, hIcon);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment