如何写注册表REG_BINARY,REG_DWORD,REG_SZ值-创新互联
这期内容当中小编将会给大家带来有关如何写注册表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值了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。
网站题目:如何写注册表REG_BINARY,REG_DWORD,REG_SZ值-创新互联
当前地址:http://pwwzsj.com/article/cesdoi.html