这期内容当中小编将会给大家带来有关如何写注册表REG_BINARY,REG_DWORD,REG_SZ值,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
在平江等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、做网站 网站设计制作按需制作,公司网站建设,企业网站建设,品牌网站建设,全网整合营销推广,成都外贸网站建设公司,平江网站建设费用合理。
inline BYTE CharToBin(TCHAR ch)
{
if(ch>='0' && ch<='9')
return ch - '0';
if(ch>='a' && ch<='f')
return ch - 'a' + 10;
if(ch>='A' && ch<= 'F')
return ch - 'A' + 10;
return 0xff;
}
inline bool Hex2Bin(LPCTSTR lpHex,LPBYTE lpBin,DWORD &dwLen)
{
LPCTSTR lpChar = lpHex;
TCHAR char1 = *lpChar;
TCHAR char2 = *(lpChar+1);
if(!char1 || !char2)
return false;
LPBYTE lpOut = lpBin;
DWORD inputBuf = dwLen;
dwLen = 0;
BYTE h = CharToBin(char1);
BYTE l = CharToBin(char2);
while(0xff != h && 0xff != l)
{
*lpOut = l | h<<4;
lpOut++;
dwLen++;
lpChar+=2;
if(inputBuf<=dwLen)
break;
h = CharToBin(*lpChar);
l = CharToBin(*(lpChar+1));
}
return true;
}
BOOL RegWrite(HKEY hKey,LPCSTR lpSubKey,LPCSTR lpValue,DWORD dwType,void* pData,DWORD dwLen)
{
if(!pData)
return FALSE;
if(REG_BINARY == dwType)
{
void* pBuffer = new BYTE[lstrlen((char*)pData)];
memset(pBuffer,0,lstrlen((char*)pData));
if(pBuffer)
{
Hex2Bin((LPCTSTR)pData,(LPBYTE)pBuffer,dwLen);
SHSetValue(hKey,lpSubKey,lpValue,REG_BINARY,pBuffer,dwLen);
delete []pBuffer;
}
}
else
{
if(REG_SZ == dwType)
{
dwLen = lstrlen((const char*)pData);
}
else if(REG_DWORD == dwType)
dwLen = 4;
SHSetValue(hKey,lpSubKey,lpValue,dwType,pData,dwLen);
}
return TRUE;
}
void main(int argc,char*argv[])
{
RegWrite(HKEY_LOCAL_MACHINE,"SOFTWARE//aaaa//","b",REG_BINARY,"123456abcdef",6);
DWORD dwValue = 1234;
RegWrite(HKEY_LOCAL_MACHINE,"SOFTWARE//aaaa//","c",REG_DWORD,&dwValue,4);
RegWrite(HKEY_LOCAL_MACHINE,"SOFTWARE//aaaa//","d",REG_SZ,"asdfgh",0);
}
上述就是小编为大家分享的如何写注册表REG_BINARY,REG_DWORD,REG_SZ值了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。