Re: Windows Version numbers for Windows 2008
- From: "mayayana" <mayaXXyana@xxxxxxxxx>
- Date: Tue, 10 Feb 2009 22:19:36 -0500
That's not uncommon. For many structures passed to API functions, you havethe
to specify the size of the structure. And this is precisely so there's
backwards compatibility among versions of Windows. I've never put it to
test, but I've always been under the impression that if you specify a
structure size larger than the version of Windows supports, you'll corrupt
memory
That would be a contradiction. There's not much
point to the backward compatibility if it won't work.
And there would be no point to specifying the allotted
size unless the function is using that as a guide to
how much data it can write.
I just found a curious thing, though, in trying various
tests. If I use an OSVERSIONINFO it works fine, and
if I use an OSVERSIONINFOEX it works fine (Win98).
In both cases I'm calling GetVersionEx. That makes sense.
But I found some odd things:
If I use
OSV.dwOSVersionInfoSize = Len(OSV) + 4
or
OSV.dwOSVersionInfoSize = 2 * Len(OSV)
or
OSV.dwOSVersionInfoSize = 164 '-- correct number is 156
it doesn't crash, but all of the members return 0!
Also, if I add extra members to the structure, like
extra1 as long
extra2 as long
it doesn't crash but all members return 0.
I assumed that I could use any size Type structure,
and send anything in the size member, as long as I
specify a size big enough and look for the data at the
right offset. But the function -- or maybe VB? -- seems
to have some kind of safety in place that prevents me
from using an invalid structure size, even when it's too big!
I can't account for that. I don't see how VB could know
about the Types, since I have to declare them, so maybe
it's built into kernel32 to check for a valid structure?
In my circa 98 copy of MSDN it has this:
lpVersionInformation
Pointer to an OSVERSIONINFO data structure that the function
fills with operating system version information. .....
Windows NT 5.0 and later: This member can be a pointer to an
OSVERSIONINFOEX structure.
It also notes, under the GetVersion listing, that GetVersionEx
is not an NT call but rather an improved version because it
returns version data in a structure rather than as a long flag
variable. So maybe the OSVERSIONEX structure was there from
the beginning; just not needed on Win9x.
So now I'm very curious what is enforcing the size of the
structure, but I think we've at least established that all
systems can use GetVersioEx and that all can use either
structure.
.
- Follow-Ups:
- Re: Windows Version numbers for Windows 2008
- From: David Youngblood
- Re: Windows Version numbers for Windows 2008
- References:
- Re: Windows Version numbers for Windows 2008
- From: MikeD
- Re: Windows Version numbers for Windows 2008
- From: mayayana
- Re: Windows Version numbers for Windows 2008
- From: MikeD
- Re: Windows Version numbers for Windows 2008
- Prev by Date: Re: Windows Version numbers for Windows 2008
- Next by Date: Re: Windows Version numbers for Windows 2008
- Previous by thread: Re: Windows Version numbers for Windows 2008
- Next by thread: Re: Windows Version numbers for Windows 2008
- Index(es):
Relevant Pages
|