救命!!!关于RegSetValueEx最后一个常数的问题!!
sense 2005-07-30 06:30:00 为什么sizeof(keyvalues)输出的总是:4
strlen(keyvalues)输出的总是:1
keyvalue.GetLength()正常
-------------------------
bool CPDADlg::SetReg(CString key,CString keyvalue,bool bFlush)
{
HKEY hKey = NULL;
DWORD dwDisp;
if(ERROR_SUCCESS != RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("\\SOFTWARE\\Apps\\MYREG"), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp))
{
return FALSE;
}
char *keyvalues;
keyvalues=(LPSTR)(LPCTSTR)keyvalue;
CString str;
str.Format(L"=%d,sizeof=%d,strlen=%d",keyvalue.GetLength(),sizeof(keyvalues),strlen(keyvalues));
MessageBoxW(keyvalue+str);
bool bRet = (ERROR_SUCCESS == RegSetValueEx(hKey, key, 0, REG_SZ, (const BYTE *)keyvalues,strlen(keyvalues)+1));
if(bFlush)
{
RegFlushKey(hKey);
}
RegCloseKey(hKey);
return bRet;
}