#if (WINVER > 0x0501)
// Vista or higher
#else
// Upto WinXP
#endif
or if you want
#if (WINVER <= 0x0501)
// Upto WinXP
#else
// Vista, ...
#endif
I'd do it this way:
- Determine the OS version using GetVersionEx
- Depending on the determined version:
a) use SHGetFolderPath
b) use SHGetKnownFolderPath
In both cases you shouldn't call SHGet... directly, because then your
program won't load if one of both functions isn't available on the
user's system. It's better to use LoadLibrary/GetModuleHandle and
GetProcAdress to retrieve the address of the function you want to use
and call the function based on this address.
So you'll end up with something like this (the code is for
SHGetKnownFolderIDList):
typedef HRESULT WINAPI SHGetKnownFolderIDListFn(REFKNOWNFOLDERID rfid,
DWORD dwFlags, HANDLE hToken, __out PIDLIST_ABSOLUTE* ppidl);
HMODULE hShell32 = GetModuleHandle(TEXT("shell32.dll"));
if(hShell32) {
pfnSHGetKnownFolderIDList =
reinterpret_cast<SHGetKnownFolderIDListFn*>(GetProcAddress(hShell32,
"SHGetKnownFolderIDList"));
if(pfnSHGetKnownFolderIDList) {
return pfnSHGetKnownFolderIDList(folderID, flags, hToken, ppIDL);
}
}
Hope this helps
Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
It says it's a wrapper for SHGetKnownFolderPath and it's always exported
Then you can use it without problem on Vista
So I will have to implement it myself? Ok then.
By the way, I am using your ExplorerTreeView control. Good work on
that Timo. I wanted to leave a thanks message on ur site but it
required me to register a username (I even tried signning up but never
got an email!). I hope you will make things less complicated for
people wanting to say 'thanks'. Keep contributing...