Ano*_*ard 13
你可以使用LoadImage:
wcex.hIcon = (HICON) LoadImage( // returns a HANDLE so we have to cast to HICON
NULL, // hInstance must be NULL when loading from a file
"iconfile.ico", // the icon file name
IMAGE_ICON, // specifies that the file is an icon
0, // width of the image (we'll specify default later on)
0, // height of the image
LR_LOADFROMFILE| // we want to load a file (as opposed to a resource)
LR_DEFAULTSIZE| // default metrics based on the type (IMAGE_ICON, 32x32)
LR_SHARED // let the system release the handle when it's no longer used
);
Run Code Online (Sandbox Code Playgroud)
确保将wcex.hIconSm(小图标)设置为NULL或加载一个小图标.将其设置为NULL时,它将自动使用hIcon指定的图像.使用LoadImage加载小图标时,应将宽度和高度设置为16并删除LR_DEFAULTSIZE标志.如果它是一个设计为透明部分的图标,请添加LR_LOADTRANSPARENT标志