Detecting Vista
Archives Forums/Win32 Discussion/Detecting Vista
| ||
Simple enough question... How can I find out if my program is running under Windows Vista? Does the environment variable %OS% return something other than "Windows_NT", as it does on XP? |
| ||
Well, as nobody answered and now that I have Vista to check this out... The environment variable OS still returns "Windows_NT", which is ever so helpful ... not. So, the only way that I can see at the moment is by checking for the user's personal folder instead (HOMEDRIVE+HOMEPATH). You see, under Vista it will start with "C:\Users\" and not "C:\Documents and Settings\", as it does under XP. Just in case anyone was interested ;o) |
| ||
Assuming your program is able to use the windows api, just use GetVersionEx. Vista returns 6.0, 2000/xp/2003 are 5.0, 5.1 and 5.2 respectively. |
| ||
Ah, those API calls, eh? I should really start to learn how to use those ;o) |
| ||
Don't suppose anybody could throw a quick example together, could they? I don't have a clue when it comes to all this Extern stuff :o( Cheers in advance. |
| ||
Here's what I've managed to come up with and it works fine on my Vista computer... I'm not sure how memory safe simply increasing the size of the type is as the system will be writing to memory outside the type structure. I tried to use a byte array to pad out the type but it simply stores a 1 byte memory pointer (I think because Max doesn't support type static arrays). :-? Hope this helps, Seb |
| ||
Thanks. Works a treat. Much appreciated. |
| ||
For Seb: I'm not sure how memory safe simply increasing the size of the type is as the system will be writing to memory outside the type structure. Changing "Field szCSDVersion:Short Ptr" into 16 Longs (128/8) should take care of that ;) EDIT: or maybe 32 if your using the Widechar version... |