ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Non MSDN online WinAPI reference?

<< < (2/3) > >>

f0dder:
edit: ok, I got it.  After masking off the hi byte I needed to shift right 8
Wish they'd just return a damn floating point number like 6.1!!  Jeez!-MilesAhead (June 11, 2009, 08:21 PM)
--- End quote ---
Floating-point is evil and imprecise, fixed-point is precise and easy-peas :)

MilesAhead:
edit: ok, I got it.  After masking off the hi byte I needed to shift right 8
Wish they'd just return a damn floating point number like 6.1!!  Jeez!-MilesAhead (June 11, 2009, 08:21 PM)
--- End quote ---
Floating-point is evil and imprecise, fixed-point is precise and easy-peas :)
-f0dder (June 12, 2009, 07:06 AM)
--- End quote ---

I'd appreciate it if they put the dot in for me, whatever they use.  The way it is now is a pita.  The lo byte's connected to the hi byte, the hi byte's connected to the shin bone yadda yadda.  There should be OSVersion() spits out 6.1 for W7 period.

f0dder:
Bitshifting is hardly rocket science :)

But use GetVersionEx with the OSVERSIONINFOEX structure, then?

MilesAhead:
Bitshifting is hardly rocket science :)

But use GetVersionEx with the OSVERSIONINFOEX structure, then?
-f0dder (June 12, 2009, 12:35 PM)
--- End quote ---

Why not OSVersion that returns "6.1" ??  Just about any compiled or scripting language can convert the string representation of a number to a numeric data type for comparison.  Instead I have to do it, then convert it back.  Pretty much a time waster.

f0dder:
Depends on how you look at it, and what you need to use the information for.

If you just need to display the version, sure, it would be nice just getting a string back. But this isn't a very common task, compared to the much more common: checking if you're running on a supported platform. It's much easier bitshifting and checking than it is to convert a string or floating-point value... besides, with the following code snippet in MSDN, what's the worry? :)


--- ---#include <windows.h>
#include <stdio.h>

void main()
{
    DWORD dwVersion, dwMajorVersion, dwMinorVersion, dwBuild;

    dwVersion = GetVersion();
 
    // Get the Windows version.

    dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
    dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

    // Get the build number.

    if (dwVersion < 0x80000000)             
        dwBuild = (DWORD)(HIWORD(dwVersion));
    else                                      // Windows Me/98/95
        dwBuild =  0;

    printf("Version is %d.%d (%d)\n",
                dwMajorVersion,
                dwMinorVersion,
                dwBuild);
}

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version