locked
Read Value from Registry RRS feed

  • Question

  • Hello this is took very long time for me, but tried a lot of diffrent methods to read registry value data but none of them worked:

    Tried this method which seems promising:

    #define BUFFER 8192

    char value[255]; DWORD BufferSize = BUFFER; RegGetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "~MHz", RRF_RT_ANY, NULL, (PVOID)&value, &BufferSize); if(value == ERROR_SUCCESS) { } printf("Value Read is %i\n", PtrToInt(value));


    Anyone could help me?


    • Edited by speed258 Tuesday, April 10, 2018 4:34 PM
    Tuesday, April 10, 2018 4:31 PM

Answers

  • (Unicode) =>

    DWORD dwValue;
    DWORD dwBufferSize;
    dwValue = sizeof(dwValue);
    if (ERROR_SUCCESS == RegGetValue(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", L"~MHz", RRF_RT_ANY, NULL, &dwValue, &dwBufferSize))	
    {
    	// Code
    }

    • Marked as answer by speed258 Tuesday, April 10, 2018 4:56 PM
    Tuesday, April 10, 2018 4:46 PM

All replies

  • (Unicode) =>

    DWORD dwValue;
    DWORD dwBufferSize;
    dwValue = sizeof(dwValue);
    if (ERROR_SUCCESS == RegGetValue(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", L"~MHz", RRF_RT_ANY, NULL, &dwValue, &dwBufferSize))	
    {
    	// Code
    }

    • Marked as answer by speed258 Tuesday, April 10, 2018 4:56 PM
    Tuesday, April 10, 2018 4:46 PM
  • (Unicode) =>

    DWORD dwValue;
    DWORD dwBufferSize;
    dwValue = sizeof(dwValue);
    if (ERROR_SUCCESS == RegGetValue(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", L"~MHz", RRF_RT_ANY, NULL, &dwValue, &dwBufferSize))	
    {
    	// Code
    }

    Thank you very much, it works.

    Also do I need to close a key?

    • Edited by speed258 Tuesday, April 10, 2018 4:59 PM
    Tuesday, April 10, 2018 4:56 PM
  • Also do I need to close a key?
    Well, did you open a key?
    Tuesday, April 10, 2018 5:18 PM
  • Seems not only get value, well ok then.
    Tuesday, April 10, 2018 6:07 PM