FindResource调用失败了
#include "stdafx.h"#include "resource.h"
#include<windows.h>
#include<stdio.h>
int CreateIco()
{
HINSTANCE hInst=GetModuleHandle(NULL);
if(hInst==NULL)
{
return 1;
}
HRSRC hRes=FindResource(hInst,MAKEINTRESOURCE(IDI_ICON1),RT_ICON);
if(hRes==NULL)
{
return 2;
}
DWORD len=SizeofResource(hInst,hRes);
HGLOBAL hg=LoadResource(hInst,hRes);//载入资源
if(hg==NULL)
{
return 3;
}
LPVOID lp=(LPSTR)LockResource(hg);//锁定资源
if(lp==NULL)
{
return 4;
}
HANDLE hFile1=CreateFile("icon.nj",GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwWrite=0;
WriteFile(hFile1,lp,len,&dwWrite,NULL);
CloseHandle(hFile1);
FreeResource(hg);
return 0;
}
int main(int argc, char* argv[])
{
int i=CreateIco();
printf("%d",i);
getchar();
return 0;
}
各位大大们 我的ico文件ID为IDI_ICON1 可是调用时FindResource函数失败 这代码有什么问题吗?