wxGetOsDescription() in Windows 7. Topic is solved
-
- Experienced Solver
- Posts: 93
- Joined: Sun Mar 15, 2009 10:28 pm
wxGetOsDescription() in Windows 7.
I don't have the Windows 7 release candidate, so all I'm asking is what would the string returned from wxGetOsDescription() look like under Windows 7? A friend of mine has it but is not currently on for me to ask.
-
- Experienced Solver
- Posts: 93
- Joined: Sun Mar 15, 2009 10:28 pm
I have three questions then:doublemax wrote:wxWidgets 2.8.9 doesn't know about Windows 7 yet, so it reports Windows NT 6.1.
But if you want to implement some OS specific code you should better use the OS version numbers from wxGetOsVersion() anyway.
6.0 = Vista
6.1 = Windows 7
1. What makes wxGetOsVersion() better than wxGetOsDescription() for this?
2. If it is instead recommended that I use wxGetOsVersion(), what version is XP? (5.0?)
3. On official release of 7, will it still remain 6.1 or will it be brought up to 7.0?
i think it's more reliable to compare integers than to compare strings1. What makes wxGetOsVersion() better than wxGetOsDescription() for this?
5.0 = Windows 20002. If it is instead recommended that I use wxGetOsVersion(), what version is XP? (5.0?)
5.1 = Windows XP
i don't know, but i believe not3. On official release of 7, will it still remain 6.1 or will it be brought up to 7.0?
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Use the source, Luke!
-
- Experienced Solver
- Posts: 93
- Joined: Sun Mar 15, 2009 10:28 pm
-
- Experienced Solver
- Posts: 93
- Joined: Sun Mar 15, 2009 10:28 pm
Actually, my program cycles through an image folder and displays the images as the background. I'm using this to determine the default pictures folder in each OS.doublemax wrote:in don't know Windows Server 2008, but if it has the same version number as Vista, i'd expect it to support the same API functions, and that's what probably matters.
Code: Select all
/**
* Returns the path to the default pictures directory for the current
* operating system
*
* @return Returns the default pictures directory path
*/
/* static */ const wxString CWindowsApi::GetPicturesPath()
{
wxString szPicturesPath = wxGetHomeDir();
// Set the default pictures directory for Windows XP
if (wxGetOsDescription().Contains(wxT("Windows XP"))) {
szPicturesPath += wxT("\\My Documents\\My Pictures");
}
// Set the default pictures directory for Windows Vista and Windows 7
else if (wxGetOsDescription().Contains(wxT("Windows Vista")) ||
wxGetOsDescription().Contains(wxT("Windows NT 6.1")))
{
// The path in Windows 7 leads to the directory "Pictures," though
// it displays as "My Pictures" to the user
szPicturesPath += wxT("\\Pictures");
}
return szPicturesPath;
}
while this may work in most cases, it's better to ask the OS for the specific path.
Win32 API has SHGetFolderLocation for that.
Here's a small snippet from wxStandardPaths::DoGetDirectory() (which is protected, so you can't use it directly):
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
The cidl for your purpose is CSIDL_MYPICTURES.
Win32 API has SHGetFolderLocation for that.
Here's a small snippet from wxStandardPaths::DoGetDirectory() (which is protected, so you can't use it directly):
Code: Select all
#include <wx/msw/wrapshl.h>
wxString winGetSpecialFolderLocation(int cidl)
{
wxString dir;
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL, cidl, &pidl);
if ( SUCCEEDED(hr) ) {
// creating this temp object has (nice) side effect of freeing pidl
dir = wxItemIdList(pidl).GetPath();
}
return dir;
}
The cidl for your purpose is CSIDL_MYPICTURES.
Use the source, Luke!
-
- Experienced Solver
- Posts: 93
- Joined: Sun Mar 15, 2009 10:28 pm