代码拉取完成,页面将自动刷新
#include "StdAfx.h"
#include "Utilities.h"
CUtilities::CUtilities()
{
}
CUtilities::~CUtilities()
{
}
BOOL CUtilities::ReleaseRes(UINT ResID,LPCTSTR lpType,LPCTSTR destFile)
{
//查找资源文件
HRSRC res = FindResource(NULL, MAKEINTRESOURCE(ResID), lpType); //实际使用时修改这里即可MAKEINTRESOURCE(IDR_SYS),TEXT("BINARY")
if (!res)
return FALSE;
//加载资源
HGLOBAL resGlobal = LoadResource(NULL, res);
if (!resGlobal)
return FALSE;
//资源文件大小
DWORD size = SizeofResource(NULL, res);
//锁定资源
BYTE* ptr = (BYTE*)LockResource(resGlobal);
if (!ptr)
return FALSE;
//创建文件 实际使用时修改XXX.sys
HANDLE hFile = CreateFile(destFile, GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
DWORD dw;
//将资数据写入文件
if (!WriteFile(hFile, ptr, size, &dw, NULL)){
CloseHandle(hFile);
return FALSE;
}
CloseHandle(hFile);
return TRUE;
}
char * wchar2char(const wchar_t* wchar)
{
char * m_char;
int len = WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), NULL, 0, NULL, NULL);
m_char = new char[len + 1];
WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), m_char, len, NULL, NULL);
m_char[len] = '\0';
return m_char;
}
wchar_t * char2wchar(const char* cchar)
{
wchar_t *m_wchar;
int len = MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), NULL, 0);
m_wchar = new wchar_t[len + 1];
MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), m_wchar, len);
m_wchar[len] = '\0';
return m_wchar;
}
BOOL hexstr2int(CDuiString sHex,int &iRet)
{
iRet = 0;
BOOL bRet = FALSE;
char* chex = wchar2char(sHex.GetData());
char*hex = chex;
int res = 0;
for (; *hex; hex++)
{
int d = toupper(*hex);
if (d >= '0' && d <= '9')d -= '0';
else
if (d >= 'A' && d <= 'F')d -= 'A' - 10;
else break;
res = res * 16 + d;
}
iRet = res;
delete[] chex;
bRet = TRUE;
return bRet;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。