Quantcast
Channel: Parallel Computing in C++ and Native Code forum
Viewing all articles
Browse latest Browse all 856

compatible calls to RegGetValue and _atoi64

$
0
0

I have some Windows API C code built as a Win32 DLL for retrieving a large integer value as a string from the registry using RegGetValue and then turning it into an __int64 using _atoi64. I've discovered a problem with this in the release build, which is that my call to RegGetValue is interpretted as a call to RegGetValueW and so returns the value in a wide char string, but the call to _atoi64 appears to always expect a normal ansi single byte char string and so doesn't return the right __int64 value for the string. I know I can explicitly call RegGetValueA, or replace the call to _atoi64 with _wtoi64 to make them agree explicitly, but I'm thinking it would be better to use an indirect function call that will automatically call either _atoi64 or _wtoi64 in agreement with the way that RegGetValue is redirected between RegGetValueA or RegGetValueW, depending upon the build settings. Does anyone know if such a function exists, and if not how I could maybe simulate it? Code follows:

    char szOffset[30] = "";
    DWORD dwDataType = 0;
    DWORD dwSize = sizeof(szOffset);
    time_t retTime = time();
    .
    .
    .
    // read reg string value ... 
    if (RegGetValue(hMyTimeKey, NULL, "Offset", RRF_RT_REG_SZ, &dwDataType, (PVOID)szOffset, &dwSize) == ERROR_SUCCESS)
    {
        // ... and add it to the system time value we just retrieved
        retTime += _atoi64(szOffset);
    }



Viewing all articles
Browse latest Browse all 856

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>