c++ - Copying DWORD from HKCU to HKLM -
having problem copying registry value hkcu hklm. dword , using code enumerate keys , copy them @ time of install.
hresult hr = s_ok; uint er = error_success; hkey hkey; char szproductkey[max_path], lszvalue[max_path]; tchar achkey[max_key_length], achclass[max_path] = text(""), achvalue[max_value_name]; dword cbname, cchclassname = max_path, csubkeys=0, cbmaxsubkey, cchmaxclass, cvalues, cchmaxvalue, cbmaxvaluedata, cbsecuritydescriptor; filetime ftlastwritetime; phkey phkresult = null; dword i, retcode, cchvalue = max_value_name,dwtype=reg_sz,dwskeyvaluesize,dwsize=255; hr = wcainitialize(hinstall, "readtempregkey"); exitonfailure(hr, "failed initialize"); wcalog(logmsg_standard, "initialized."); orc_reg_sub_lm_cu(); sprintf_s(szproductkey, "software\\m\\%s",orc_get_product_name()); wcalog(logmsg_standard , szproductkey); if( regopenkeyex( hkey_current_user, szproductkey, 0, key_read, &hkey) == error_success ) { //get class name , value count. retcode = regqueryinfokey( hkey, // key handle achclass, // buffer class name &cchclassname, // size of class string null, // reserved &csubkeys, // number of subkeys &cbmaxsubkey, // longest subkey size &cchmaxclass, // longest class string &cvalues, // number of values key &cchmaxvalue, // longest value name &cbmaxvaluedata, // longest value data &cbsecuritydescriptor, // security descriptor &ftlastwritetime); // last write time // enumerate subkeys, until regenumkeyex fails. if (csubkeys) { (i=0; i<csubkeys; i++) { cbname = max_key_length; retcode = regenumkeyex(hkey, i, achkey, &cbname, null, null, null, &ftlastwritetime); } } //enumerate key values. if (cvalues) { (i=0, retcode=error_success; i<cvalues; i++) { cchvalue = max_value_name; achvalue[0] = '\0'; retcode = regenumvalue(hkey, i, achvalue, &cchvalue, null, null, null, null); if (retcode == error_success ) { dword dwsize = sizeof(lszvalue); retcode = regqueryvalueex(hkey, achvalue, null, &dwtype,(lpbyte)&lszvalue, &dwsize); if (retcode == error_success) { orc_reg_stop_lm_cu(); dwskeyvaluesize = strlen((char*) lszvalue); orc_regvalue(hkey_local_machine, "software\\m\\orchestrator", key_set_value, achvalue, &dwtype, (unsigned char *)lszvalue, &dwskeyvaluesize); } } } } } after copy value registry correct data says invalid dword 32-bit value know cause this?
thanks
you invalid dword 32-bit value message because last parameter passed orc_regvalue() incorrect. correct value reg_dword data type sizeof(dword).
try passing dwsize instead of dwskeyvaluesize
orc_regvalue(hkey_local_machine, "software\\m\\orchestrator", key_set_value, achvalue, &dwtype, (unsigned char *)lszvalue, &dwsize); alternatively can try
dwskeyvaluesize = dwsize; instead of
dwskeyvaluesize = strlen((char*) lszvalue);
Comments
Post a Comment