Guest crystal160@gmail.com Posted September 5, 2007 Posted September 5, 2007 i am working with these, dwMajorVersion dwMinorVersion dwBuildNumber dwPlatformId wServicePackMajor wServicePackMinor 1) So, dwMinorVersion (1) could only be Windows XP and dwMajorVersion (6) could only be Windows Vista or Windows Server 2008? 2) So, if I had dwMinorVersion (1) and wServicePackMajor (1) that could only be Windows XP SP1? 3) So, if I had dwMinorVersion (1) and wServicePackMajor (2) that could only be Windows XP SP2? 4) Would dwMajorVersion (6) and wServicePackMajor (1) be possible? Thank you. I am hoping these scattered questions will help me understand this. Crystal
Guest Andrew McLaren Posted September 5, 2007 Posted September 5, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) <crystal160@gmail.com> wrote ... >i am working with these, > dwMajorVersion > dwMinorVersion > dwBuildNumber > dwPlatformId > wServicePackMajor > wServicePackMinor > 1) So, dwMinorVersion (1) could only be Windows XP and dwMajorVersion > (6) could only be Windows Vista or Windows Server 2008? > 2) So, if I had dwMinorVersion (1) and wServicePackMajor (1) that > could only be Windows XP SP1? > 3) So, if I had dwMinorVersion (1) and wServicePackMajor (2) that > could only be Windows XP SP2? > 4) Would dwMajorVersion (6) and wServicePackMajor (1) be possible? Hi Crystal, It sounds like a trick question :-). You're saying, in effect: "I want to examine a subset of my OSVERSIONINFOEX struct, and extrapolate the value of other OSVERSIONINFOEX fields based on this subset". That's always going to be risky programming: basically, it's trying to conjure information out of thin air. I suspect that dwMajorVersion (6) and wServicePackMajor (1) will certainly be possible and common, once Service Pack 1 for Vista has been released. dwMinorVersion (1) and wServicePackMajor (1) could easily prove to be an as-yet unnanounced version of Windows like Vista R2 SP1, or similar - there's no gurantee it will always be limited to Windows XP SP1. Likewise, dwMinorVersion (1) and wServicePackMajor (2) may end up equalling both XP SP2 *and* Windows Server 2008 R2, SP2. We just don't know. We already saw huge bugs in 3rd party applications for Windows 3.1, which did: if (MinorVersion < 10) { Error("This program requires Windows 3.1"); } Windows 95 required a special comptibility fix to let all these programs run. The programs had no technical incompatibility with Windows 95; but they refused to run because of their broken MinorVersion check. Meanwhile, users blasted Microsoft for "breaking compatibility". So, my question for you is: how are you getting these dwMajorVersion, etc values? I'm assuming that you are calling GetVersionEx() or VerifyVersionInfo(). If you call weither of thee functions you will get a fully populated OSVERSIONINFOEX struct. This gives you all the information you need to determine the exact version of Windows - even versions which don't exist yet. So, what are you trying to achieve, by manipulating a subset of this information? What resource are you trying to conserve, while making you application more fragile and error prove in its version checking? -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest crystal160@gmail.com Posted September 5, 2007 Posted September 5, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > So, my question for you is: how are you getting these dwMajorVersion, etc > values? I'm assuming that you are calling GetVersionEx() or > VerifyVersionInfo(). If you call weither of thee functions you will get a > fully populated OSVERSIONINFOEX struct. This gives you all the information > you need to determine the exact version of Windows - even versions which > don't exist yet. So, what are you trying to achieve, by manipulating a > subset of this information? What resource are you trying to conserve, while > making you application more fragile and error prove in its version checking? Very Interesting! I think see what you mean.... I am indeed using GetVersionEx() to get the fully populated OSVERSIONINFOEX. So, based on this data, how can I pluck it to come to the conclusion I am dealing with, 1) a Windows XP version less than Windows XP2, and 2) a Windows Vista machine? I want to limit constraints to 1 & 2, so... like server editions, Windows 2003 or whatnot should be ignored/not identified. :) :) Can that be done? Crystal
Guest Andrew McLaren Posted September 5, 2007 Posted September 5, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > I am indeed using GetVersionEx() to get the fully populated > OSVERSIONINFOEX. > > So, based on this data, how can I pluck it to come to the conclusion I > am dealing with, 1) a Windows XP version less than Windows XP2, and 2) > a Windows Vista machine? I want to limit constraints to 1 & 2, so... > like server editions, Windows 2003 or whatnot should be ignored/not > identified. :) :) Can that be done? Of course! :-) The trick is that you must *never* make decisions based on dwMinorVersion alone, without an explicit dwMajorVersion context for it. Generally, you'd want to use dwMajorVersion and dwMinorVersion togther, to make sure the version context is clear: if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) printf ("Gee, it must be Vista Service Pack 1!"); if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) { if( osvi.wProductType == VER_NT_WORKSTATION ) printf ("It is Windows Vista"); else printf ("It is Windows Server 2008" ); } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) printf ("It is Microsoft Windows XP "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) printf ("It is Microsoft Windows 2000 "); There are many code samples in MSDN, see here for a good starting point: http://msdn2.microsoft.com/en-us/library/ms724429.aspx Hope it helps, -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest crystal160@gmail.com Posted September 5, 2007 Posted September 5, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) > printf ("It is Microsoft Windows XP "); Ah! Very good and I do believe I have a clear understanding. Just to verify, within the subset of Windows XP, am I right in my logic below? :) if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) printf ("It is Microsoft Windows XP Home or Professional SP1"); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) printf ("It is Microsoft Windows XP Home or Professional SP2");
Guest Andrew McLaren Posted September 6, 2007 Posted September 6, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) <crystal160@gmail.com> wrote ... > Just to verify, within the subset of Windows XP, am I right in my > logic below? :) > > if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) > printf ("It is Microsoft Windows XP Home or Professional > SP1"); > > if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) > printf ("It is Microsoft Windows XP Home or Professional > SP2"); No! No, no, no. That code will give you the wrong results. (dwMajorVersion == 5 && dwMinorVersion == 1) includes *all* releases of 32-bit XP; including RTM, SP1, SP2; and SP3 when it finally ships. (dwMajorVersion == 5 && dwMinorVersion == 2) is Windows Server 2003 R2, Server 2003, or XP x64. dwMinorVersion does not give you any information about Service Pack level. It indicates the minor version, that is all. The Service Pack version is indicated by wServicePackMajor and wServicePackMinor. Did you look at the code sample in the URL I sent you? - http://msdn2.microsoft.com/en-us/library/ms724429.aspx Everything you need to know, is there. if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) { printf ("It is Microsoft Windows XP Home or Professional "); { if ( osvi.wServicePackMajor == 0 ) printf ("with no Service Pack"); else if ( osvi.wServicePackMajor == 1 ) printf ("with Service Pack 1"); else if ( osvi.wServicePackMajor == 2 ) printf ("with Service Pack 2"); else printf ("unrecognised Service Pack"); } } You need to read and understand the MSDN documentation. That is more reliable, than trusting random fools in newsgroups: http://msdn2.microsoft.com/en-us/library/ms724833.aspx -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest purposegreen@gmail.com Posted September 6, 2007 Posted September 6, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > than trusting random fools in newsgroups L0L, you don't seem like one :D Finally, I want to ask, please look at this: if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) printf ("Gee, it must be Vista Service Pack 1!"); Can one determine Windows Vista service pack releases the same way as calculated with Windows XP? so, like if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) { printf ("It is Microsoft Windows Vista All Versions"); { if ( osvi.wServicePackMajor == 0 ) printf ("with no Service Pack"); else if ( osvi.wServicePackMajor == 1 ) printf ("with Service Pack 1"); else if ( osvi.wServicePackMajor == 2 ) printf ("with Service Pack 2"); else if ( osvi.wServicePackMajor == 3 ) printf ("with Service Pack 3"); else if ( osvi.wServicePackMajor == 4 ) printf ("with Service Pack 4"); else printf ("unrecognised Service Pack"); } } It is slightly exaggerated, but will it work? I noted you have this: if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) { if( osvi.wProductType == VER_NT_WORKSTATION ) printf ("It is Windows Vista"); else printf ("It is Windows Server 2008" ); } Is above just an alternative way to get to the same information? :D
Guest passssifit@gmail.com Posted September 6, 2007 Posted September 6, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) On Sep 5, 9:25 pm, purposegr...@gmail.com wrote: > > than trusting random fools in newsgroups > > L0L, you don't seem like one :D > > Finally, I want to ask, > > please look at this: > > if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) > printf ("Gee, it must be Vista Service Pack 1!"); > > Can one determine Windows Vista service pack releases the same way as > calculated with Windows XP? > > so, like > > if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) > { > printf ("It is Microsoft Windows Vista All Versions"); > { > if ( osvi.wServicePackMajor == 0 ) > printf ("with no Service Pack"); > else if ( osvi.wServicePackMajor == 1 ) > printf ("with Service Pack 1"); > else if ( osvi.wServicePackMajor == 2 ) > printf ("with Service Pack 2"); > else if ( osvi.wServicePackMajor == 3 ) > printf ("with Service Pack 3"); > else if ( osvi.wServicePackMajor == 4 ) > printf ("with Service Pack 4"); > else printf ("unrecognised Service Pack"); > } > } > > It is slightly exaggerated, but will it work? I noted you have this: > > if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) > { > if( osvi.wProductType == VER_NT_WORKSTATION ) > printf ("It is Windows Vista"); > else printf ("It is Windows Server 2008" ); > } > > Is above just an alternative way to get to the same information? :D i hope this different view is satisfactory -- no?
Guest Andrew McLaren Posted September 7, 2007 Posted September 7, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > Finally, I want to ask, > please look at this: > Is above just an alternative way to get to the same information? :D Is there some specific technical question you are not clear about? Or are you just looking for general confirmation? Everything you need to know about GetVersionEx() is in the MSDN URLs I gave you. If the answer is not obvious from those links, read them again; repeat, until the answer is obvious. I can answer questions forever; but eventually you need exercise your own analytical powers. -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest crystal160@gmail.com Posted September 7, 2007 Posted September 7, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > Andrew McLaren > amclar (at) optusnet dot com dot au No worries Andrew, thank you for your time and I appreciate it. I am assuming you are singing off -- it is critical to me to get confirmations, (like I was trained by a guy from Singapore -- who always preached, 'trust, but re-confirm'". therefore, when there are blank spaces, I try not to play word volleyball, just be polite and understand sometimes conversationalists on-balance sometimes one wishes.
Guest Andrew McLaren Posted September 7, 2007 Posted September 7, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) Cool. If I thought you really needed further guidance to achieve understanding, I'd happily give it to you. But I think you have all the tools you need. Study the MSDN docs and look at the code samples in MSDN. The rest is up to you. You can also experiment with testing your code and verifying the behaviour. If you install a tool like Virtual PC: http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx you can have XP, XP SP1, XP SP2, Server 2003 and Vista, all running on the one machine at the same time. This will make it easier to test your application and/or explore the behaviour of APIs, on different versions of Windows. If you get stuck on a specific technical question regarding the OSVERSIONINFOEX struct, try asking on microsoft.public.win32.programmer.ui. GetVersionEx() and related functions aren't "UI" as such, but that is probably the closest appropriate group. BTW here's a fairly good article I just noticed while browsing CodeGuru: http://www.codeguru.com/cpp/w-p/system/systeminformation/article.php/c8973__1/ Marius covers the same ground as MSDN but in a more narrative, digestible style. Besides, I like Romanian programmers :-) Good luck with the project! -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest crystal160@gmail.com Posted September 7, 2007 Posted September 7, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > BTW here's a fairly good article I just noticed while browsing CodeGuru: > http://www.codeguru.com/cpp/w-p/system/systeminformation/article.php/... > Marius covers the same ground as MSDN but in a more narrative, digestible > style. Besides, I like Romanian programmers :-) I am actually very poor (no kidding), ... I do not have vista, but can you confirm yay or nay if the last code blob was correct, or is it just simply not documented or clear as of yet? thank you for the right push :D :D have a fabulous day!! thank you for the encouragement, I am working hard on it. I'll definitely want to re-test it, and confirm, but it's nice to know someone who is fully digested in the material to give grace to what is.
Guest Andrew McLaren Posted September 7, 2007 Posted September 7, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) <crystal160@gmail.com> wrote in message news:1189159692.293777.241540@22g2000hsm.googlegroups.com... > I am actually very poor (no kidding), ... I do not have vista, Download the 30 day Eval Vista VHD and run it in Virtual PC. Both Virtual PC and the Eval VHD are free (apart from cost of download). Thsi will give you a chance to run your compiled code on Vista and verify the results (assuming Vista is a target platform for your code): http://www.microsoft.com/downloads/details.aspx?familyid=c2c27337-d4d1-4b9b-926d-86493c7da1aa&displaylang=en&tm > but can > you confirm yay or nay if the last code blob was correct, or is it > just simply not documented or clear as of yet? thank you for the > right push :D :D have a fabulous day!! It is correct. Except, you said .... > if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) It should be ... if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) Vista and Server 2008 are Windows 6.0. Windows 6.1 hasn't been announced; we don't know what 6.1 will be, if anything (next major release is expected to be Windows 7.0). > if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) > { > if( osvi.wProductType == VER_NT_WORKSTATION ) > printf ("It is Windows Vista"); > else printf ("It is Windows Server 2008" ); > } > > Is above just an alternative way to get to the same information? :D No. The code here is specifically querying wProductType, to determine the Product Type. This is not an alternative path to any information contained in the other OSVERSIONINFOEX fields - the fields are all orthogonal: - dwMajorVersion tells you the Major Version of Windows. It does *not* tell you anything about the Service Pack level or Product Type. - wServicePackMajor tells you the major version of Service Pack. It does *not* tell you anything about the major version of Windows or Product Type. - ProductType tells you the Product Type. It does *not* tell you anything about the Windows Version or Service Pack level. - and so on ... Seriously - the MSDN doco is very clear and straightforward here. Read it. If you don't understand, read it again. If you still don't understand, read it again. If you still don't understand, read it again. There are no undocumented mysteries about GetVersionEx() or OSVERSIONINFOEX which you cannot discover just by reading the MSDN doco. If you still don't understand, read it again. If you still don't understand, read it again. If you still don't understand, read it again. Good luck, -- Andrew McLaren amclar (at) optusnet dot com dot au
Guest crystal160@gmail.com Posted September 8, 2007 Posted September 8, 2007 Re: values for Windows version (dwMajorVersion, wServicePackMajor stuff) > Good luck, > -- Thank you. you have been most helpful, and accurate.
Recommended Posts