Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AGD011

Problems retrieving system info from registry

This topic is 5498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to retrieve the ComputerName and print it to a text file. My error checking keeps telling me that there is an error when attempting to retrieve the value of the registry key. I''ve pasted the section of code below. I think it has something to do with the fact that the ComputerName I''m trying to query is a string and not an int.....Anybody have any ideas...I''m totally new to registry programming. All help is greatly appreciated! Thank you in advance! Alex HKEY hKey; DWORD dwSize = 0; DWORD dwDataType = 0; DWORD dwValue = 0; if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\ComputerName\\ComputerName", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { // Get Computer Name dwSize = sizeof(dwValue); if(::RegQueryValueEx(hKey, "ComputerName", 0, &dwDataType, reinterpret_cast(&dwValue), &dwSize) != ERROR_SUCCESS) { // Close key ::RegCloseKey(hKey); // Error handling; cout << "Error Quering Value" << endl; fout << "Error Quering Value" << endl; } // Close key ::RegCloseKey(hKey); } else { // Error handling; cout << "Error Opening the Key" << endl; fout << "Error Opening the Key" << endl; }

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!