c++ - How to check if the (default) value has not been set in the registry -
i need check if (default) value has not been set in registry using c++. whenever value has not been set , try access value, program crashes, , don't know how check if value has been set. here code:
dword valuelength = 256; char* value = new char[valuelength]; auto queryvalueerrorcode = regqueryvalueex(key, null, null, null, (lpbyte) value, &valuelength); while(queryvalueerrorcode == error_more_data) { valuelength += 256; char* newvalue = new char[valuelength]; delete[] value; value = newvalue; queryvalueerrorcode = regqueryvalueex(key, null, null, null, (lpbyte) newvalue, &valuelength); } this code doesn't crash - when try access value when crashes, have check if value has been set or not.
the (default) value not exist until has been set, check error code for
error_file_not_found before trying access value.
Comments
Post a Comment