Evening,
As I've never tried Vista and have no intention in doing so, I'm not really that familiar with the functions that is required to use when trying to make programs work for others than myself.
So, to the problem. SHGetFolderPath works fine when trying to find 'Program Files' in Windows XP, but this function is deprecated in Vista, and you should use SHGetKnownFolderPath instead. And that is my problem.
I wrote a small bit of code to determine which OS the user is using, but my compiler cannot find the needed function. It looks something like this:
Code:
/* Determine OS version */
OSVERSIONINFO osvi = GetOSVersion();
char cBuffer[5];
sprintf(cBuffer, "%u%u%u%u", osvi.dwMajorVersion >> 16, osvi.dwMajorVersion & 0xFFFF, osvi.dwMinorVersion >> 16, osvi.dwMinorVersion & 0xFFFF);
int nVersion = atoi(cBuffer);
if (nVersion > 501) // Vista or higher
{
if (SHGetKnownFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, szPath) != S_OK)
{
std::cout << "[ERROR]\n";
system("PAUSE");
return 0;
}
}
else // xp or lower
{
if (SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, szPath) != S_OK)
{
std::cout << "[ERROR]\n";
system("PAUSE");
return 0;
}
}
/* End Determine OS version */
The SHGetKnownFolderPath function is, I'm pretty sure, used wrong, but as the compiler cannot even find the function I haven't bothered trying to use it right. I've been told that I should download the Vista SDK, but my current Windows version won't allow me to do this, so I'm asking here if anyone have any ideas.