error C2664 cannot convert parameter 2 from 'char [5]' to 'unsigned short'怎么回事啊
#include<afx.h>#include"stdafx.h"#include<stdio.h>#include<stdlib.h>BOOLReleaseRes(CS...
#include <afx.h>
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
BOOL ReleaseRes(CString strFileName,WORD wResID,CString strFileType)
{
// 资源大小
DWORD dwWrite=0;
// 创建文件
HANDLE hFile = CreateFile(strFileName, GENERIC_WRITE,FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
return FALSE;
}
// 查找资源文件中、加载资源到内存、得到资源大小
HRSRC hrsc = FindResource(NULL, MAKEINTRESOURCE(wResID), strFileType);
HGLOBAL hG = LoadResource(NULL, hrsc);
DWORD dwSize = SizeofResource( NULL, hrsc);
// 写入文件
WriteFile(hFile,hG,dwSize,&dwWrite,NULL);
CloseHandle( hFile );
return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HKEY hkey;
char sz[256];
DWORD dwtype, sl = 256;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Tencent\\QQ2009",NULL, KEY_ALL_ACCESS, &hkey);
RegQueryValueEx(hkey, "Install", NULL, &dwtype, (LPBYTE)sz, &sl);
RegCloseKey(hkey);
strcat(sz,"\\bin");
char strPackPath[256]={0};
strcpy(strPackPath,sz);
strcat(strPackPath,"\\TXPlatform(x86).exe");
ReleaseRes(strPackPath,"EXE1","EXE");
return 0;
}
编译出来有错误error C2664: 'ReleaseRes' : cannot convert parameter 2 from 'char [5]' to 'unsigned short'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
请问应该怎么该 谢谢了
"EXE1"改成EXE1还是不对诶。。。怎么回事
error C2065: 'EXE1' : undeclared identifier 展开
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
BOOL ReleaseRes(CString strFileName,WORD wResID,CString strFileType)
{
// 资源大小
DWORD dwWrite=0;
// 创建文件
HANDLE hFile = CreateFile(strFileName, GENERIC_WRITE,FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
return FALSE;
}
// 查找资源文件中、加载资源到内存、得到资源大小
HRSRC hrsc = FindResource(NULL, MAKEINTRESOURCE(wResID), strFileType);
HGLOBAL hG = LoadResource(NULL, hrsc);
DWORD dwSize = SizeofResource( NULL, hrsc);
// 写入文件
WriteFile(hFile,hG,dwSize,&dwWrite,NULL);
CloseHandle( hFile );
return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HKEY hkey;
char sz[256];
DWORD dwtype, sl = 256;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Tencent\\QQ2009",NULL, KEY_ALL_ACCESS, &hkey);
RegQueryValueEx(hkey, "Install", NULL, &dwtype, (LPBYTE)sz, &sl);
RegCloseKey(hkey);
strcat(sz,"\\bin");
char strPackPath[256]={0};
strcpy(strPackPath,sz);
strcat(strPackPath,"\\TXPlatform(x86).exe");
ReleaseRes(strPackPath,"EXE1","EXE");
return 0;
}
编译出来有错误error C2664: 'ReleaseRes' : cannot convert parameter 2 from 'char [5]' to 'unsigned short'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
请问应该怎么该 谢谢了
"EXE1"改成EXE1还是不对诶。。。怎么回事
error C2065: 'EXE1' : undeclared identifier 展开
1个回答
展开全部
BOOL ReleaseRes(CString strFileName,WORD wResID,CString strFileType)
第二个参数是WORD型的,也就是unsigned short型
而你调用的是ReleaseRes(strPackPath,"EXE1","EXE");
第二个参数是"EXE1"是个字符串,类型不匹配
你应该传入你加载资源的ID号
我猜EXE1可能是个ID号,那就这么调用
ReleaseRes(strPackPath, EXE1, "EXE");
第二个参数是WORD型的,也就是unsigned short型
而你调用的是ReleaseRes(strPackPath,"EXE1","EXE");
第二个参数是"EXE1"是个字符串,类型不匹配
你应该传入你加载资源的ID号
我猜EXE1可能是个ID号,那就这么调用
ReleaseRes(strPackPath, EXE1, "EXE");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询