Detecting 16bit or 32bit OS 
Author Message
 Detecting 16bit or 32bit OS

Hi All,
I need to create a loader program that has to detect whether it's
running Win95 or Win 3.1, can anyone suggest a quick api call to do
this?

TIA

--
Jim Katz
CTO iTradeZone,Inc.
http://www.*-*-*.com/ ~jimkatz/
ICQ 9891427
Using Clarion for Windows
Always looking for the simpler solution.



Tue, 21 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Jim,



Quote:
>Hi All,
>I need to create a loader program that has to detect whether it's
>running Win95 or Win 3.1, can anyone suggest a quick api call to do
>this?

GetVersion api will return the version number (3.1 etc. or 4.0 for
Win95)  It returns a DWORD and here is how it's parses it:

"The low-order word of the return value contains the version of
Windows, if the function is successful. The high-order byte contains
the minor version (revision) number as a two-digit decimal number. For
example, in Windows 3.1, the minor version number is 10. The low-order
byte contains the major version number.

The high-order word contains the version of MS-DOS, if the function is
successful. The high-order byte contains the major version; the
low-order byte contains the minor version (revision) number.

Example

The following example uses the GetVersion function to display the
Windows and MS-DOS version numbers:

int len;
char szBuf[80];
DWORD dwVersion;

dwVersion = GetVersion();

len = sprintf(szBuf, "Windows version %d.%d\n",
    LOBYTE(LOWORD(dwVersion)),
    HIBYTE(LOWORD(dwVersion)));

sprintf(szBuf + len, "MS-DOS version %d.%d",
    HIBYTE(HIWORD(dwVersion)),
    LOBYTE(HIWORD(dwVersion)));

MessageBox(NULL, szBuf, "GetVersion", MB_ICONINFORMATION);

Note that the major and minor version information is reversed between
the Windows version and MS-DOS version. "

This was for 16bit api.  The 32bit api is GetVersionEx which is
different and returns more info:

BOOL GetVersionEx(
    LPOSVERSIONINFO  lpVersionInformation       // points to version information structure
   );

typedef struct _OSVERSIONINFO{

    DWORD dwOSVersionInfoSize;
    DWORD dwMajorVersion;
    DWORD dwMinorVersion;
    DWORD dwBuildNumber;
    DWORD dwPlatformId;
    TCHAR szCSDVersion[ 128 ];

Quote:
} OSVERSIONINFO;

Some additional info:

"The OSVERSIONINFO data structure contains operating system version
information. The information includes major and minor version numbers,
a build number, a platform identifier, and descriptive text about the
operating system. This structure is used with the GetVersionEx
function.

Members

dwOSVersionInfoSize

Specifies the size, in bytes, of this data structure. Set this member
to sizeof
(OSVERSIONINFO) before calling the GetVersionEx function.

dwMajorVersion

Identifies the major version number of the operating system. For
example, the major version number of the Daytona release of Windows NT
is 3.

dwMinorVersion

Identifies the minor version number of the operating system. For
example, the minor version number of the Daytona release of Windows NT
is 5.

dwBuildNumber

Identifies the build number of the operating system in the low-order
word. (The high-order word contains the major and minor version
numbers.)

dwPlatformId

Identifies the platform supported by the operating system.  
This member can have one of the following values:

Value   Platform
VER_PLATFORM_WIN32s     Win32s on Windows 3.1
VER_PLATFORM_WIN32_WINDOWS      Win32 on Windows 95
VER_PLATFORM_WIN32_NT   Windows NT
szCSDVersion

Contains a zero-terminated string that provides arbitrary additional
information about the operating system."

Hope this may be of some help:)

Best regards,

Arnor Baldvinsson        
[Team Topspeed - Internet Connect]
Allerup Edb
Denmark

http://www.icetips.com
UIN nr.: 2428601



Tue, 21 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Arnor,
Thanks for the reply.  Unfortunately GetVersion is not the API call I'm looking for or I am
somehow mis-using it.
Since CW does not have any functions like HiWord, LoWord, HiByte or LoByte. I simply created
two equates:
Win31                Equate(3)
Win95                Equate(4)
Then I band them against the result returned by GetVersion.  What I have found is that if I
compile 32bits I get Win95  and if I compile 16bit I get Win31. So apparently GetVersion
returns the Version of the running program not the OS. My loader has to be 16bit and be able
to detect if it's running under Win 95 or Win 3.1x. Any other suggestions?

TIA

Quote:

> Hi Jim,



> >Hi All,
> >I need to create a loader program that has to detect whether it's
> >running Win95 or Win 3.1, can anyone suggest a quick api call to do
> >this?

> GetVersion api will return the version number (3.1 etc. or 4.0 for
> Win95)  It returns a DWORD and here is how it's parses it:

> "The low-order word of the return value contains the version of
> Windows, if the function is successful. The high-order byte contains
> the minor version (revision) number as a two-digit decimal number. For
> example, in Windows 3.1, the minor version number is 10. The low-order
> byte contains the major version number.

> The high-order word contains the version of MS-DOS, if the function is
> successful. The high-order byte contains the major version; the
> low-order byte contains the minor version (revision) number.

> Example

> The following example uses the GetVersion function to display the
> Windows and MS-DOS version numbers:

> int len;
> char szBuf[80];
> DWORD dwVersion;

> dwVersion = GetVersion();

> len = sprintf(szBuf, "Windows version %d.%d\n",
>     LOBYTE(LOWORD(dwVersion)),
>     HIBYTE(LOWORD(dwVersion)));

> sprintf(szBuf + len, "MS-DOS version %d.%d",
>     HIBYTE(HIWORD(dwVersion)),
>     LOBYTE(HIWORD(dwVersion)));

> MessageBox(NULL, szBuf, "GetVersion", MB_ICONINFORMATION);

> Note that the major and minor version information is reversed between
> the Windows version and MS-DOS version. "

> This was for 16bit api.  The 32bit api is GetVersionEx which is
> different and returns more info:

> BOOL GetVersionEx(
>     LPOSVERSIONINFO  lpVersionInformation       // points to version information structure
>    );

> typedef struct _OSVERSIONINFO{

>     DWORD dwOSVersionInfoSize;
>     DWORD dwMajorVersion;
>     DWORD dwMinorVersion;
>     DWORD dwBuildNumber;
>     DWORD dwPlatformId;
>     TCHAR szCSDVersion[ 128 ];
> } OSVERSIONINFO;

> Some additional info:

> "The OSVERSIONINFO data structure contains operating system version
> information. The information includes major and minor version numbers,
> a build number, a platform identifier, and descriptive text about the
> operating system. This structure is used with the GetVersionEx
> function.

> Members

> dwOSVersionInfoSize

> Specifies the size, in bytes, of this data structure. Set this member
> to sizeof
> (OSVERSIONINFO) before calling the GetVersionEx function.

> dwMajorVersion

> Identifies the major version number of the operating system. For
> example, the major version number of the Daytona release of Windows NT
> is 3.

> dwMinorVersion

> Identifies the minor version number of the operating system. For
> example, the minor version number of the Daytona release of Windows NT
> is 5.

> dwBuildNumber

> Identifies the build number of the operating system in the low-order
> word. (The high-order word contains the major and minor version
> numbers.)

> dwPlatformId

> Identifies the platform supported by the operating system.
> This member can have one of the following values:

> Value   Platform
> VER_PLATFORM_WIN32s     Win32s on Windows 3.1
> VER_PLATFORM_WIN32_WINDOWS      Win32 on Windows 95
> VER_PLATFORM_WIN32_NT   Windows NT
> szCSDVersion

> Contains a zero-terminated string that provides arbitrary additional
> information about the operating system."

> Hope this may be of some help:)

> Best regards,

> Arnor Baldvinsson
> [Team Topspeed - Internet Connect]
> Allerup Edb
> Denmark

> http://www.icetips.com
> UIN nr.: 2428601

--
Jim Katz
CTO iTradeZone,Inc.
http://www.iag.net/~jimkatz/
ICQ 9891427
Using Clarion for Windows
Always looking for the simpler solution.


Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Jim,



Quote:
>Thanks for the reply.  Unfortunately GetVersion is not the API call I'm looking for or I am
>somehow mis-using it.
>Since CW does not have any functions like HiWord, LoWord, HiByte or LoByte. I simply created
>two equates:
>Win31                Equate(3)
>Win95                Equate(4)
>Then I band them against the result returned by GetVersion.  What I have found is that if I
>compile 32bits I get Win95  and if I compile 16bit I get Win31. So apparently GetVersion
>returns the Version of the running program not the OS. My loader has to be 16bit and be able
>to detect if it's running under Win 95 or Win 3.1x. Any other suggestions?

After playing with this for a bit I get this to work fine in 16bit,
but GetVersionExA GPF's in 32bit...  In 16bit I have prototyped it as

 Module('Win16.lib')
   GetVersion,RAW,Pascal,USHORT
 End

and then use it in a function that returns a string:

WV        USHORT
HighBytes USHORT
LowBytes  USHORT

  Code
  WV = GetVersion()
  HighBytes = BSHIFT(WV,-8)
  WV = BSHIFT(WV,8)
  LowBytes = BSHIFT(WV,-8)
  RETURN(CLIP(LowBytes) & '.' & CLIP(HighBytes))

This returns 3.95 for Win95 (which should be correct - sorry if I
stated that it should return 4.0 for Win95, it's 3.95;)  Prototyping
the 32bit function as the WinAPI etc. results in GetVersionExA returns
false and then GPF's in the RTL.  My 32bit api states that it's
GetVersionEx, not GetVersionExA but GetVersionEx is unresolved in
Win32.lib.

If the loader is 16bit only, you should be able to use the 16bit
GetVersion() function.

Best regards,

Arnor Baldvinsson        
[Team Topspeed - Internet Connect]
Allerup Edb
Denmark

http://www.icetips.com
UIN nr.: 2428601



Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Thanks Arnor,
It was the 3.95 that did the trick. I created a new "Version" equate for Windows 95 i.e.
Win95        Equate(5F03H)
and simply Band'd it against WV. Always looking for the simpler solution<g>.

Quote:

> Hi Jim,



> >Thanks for the reply.  Unfortunately GetVersion is not the API call I'm looking for or I am
> >somehow mis-using it.
> >Since CW does not have any functions like HiWord, LoWord, HiByte or LoByte. I simply created
> >two equates:
> >Win31                Equate(3)
> >Win95                Equate(4)
> >Then I band them against the result returned by GetVersion.  What I have found is that if I
> >compile 32bits I get Win95  and if I compile 16bit I get Win31. So apparently GetVersion
> >returns the Version of the running program not the OS. My loader has to be 16bit and be able
> >to detect if it's running under Win 95 or Win 3.1x. Any other suggestions?

> After playing with this for a bit I get this to work fine in 16bit,
> but GetVersionExA GPF's in 32bit...  In 16bit I have prototyped it as

>  Module('Win16.lib')
>    GetVersion,RAW,PASCAL,USHORT
>  End

> and then use it in a function that returns a string:

> WV        USHORT
> HighBytes USHORT
> LowBytes  USHORT

>   Code
>   WV = GetVersion()
>   HighBytes = BSHIFT(WV,-8)
>   WV = BSHIFT(WV,8)
>   LowBytes = BSHIFT(WV,-8)
>   RETURN(CLIP(LowBytes) & '.' & CLIP(HighBytes))

> This returns 3.95 for Win95 (which should be correct - sorry if I
> stated that it should return 4.0 for Win95, it's 3.95;)  Prototyping
> the 32bit function as the WinAPI etc. results in GetVersionExA returns
> false and then GPF's in the RTL.  My 32bit api states that it's
> GetVersionEx, not GetVersionExA but GetVersionEx is unresolved in
> Win32.lib.

> If the loader is 16bit only, you should be able to use the 16bit
> GetVersion() function.

> Best regards,

> Arnor Baldvinsson
> [Team Topspeed - Internet Connect]
> Allerup Edb
> Denmark

> http://www.icetips.com
> UIN nr.: 2428601

--
Jim Katz
CTO iTradeZone,Inc.
http://www.iag.net/~jimkatz/
ICQ 9891427
Using Clarion for Windows
Always looking for the simpler solution.


Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Jim,



Quote:
>It was the 3.95 that did the trick. I created a new "Version" equate for Windows 95 i.e.
>Win95        Equate(5F03H)
>and simply Band'd it against WV. Always looking for the simpler solution<g>.

Good:)  Any ideas why the 32bit version would fail?  Can't see any
reason for it...  Compared the prototype to my api docs and it seems
to be correct.

Best regards,

Arnor Baldvinsson        
[Team Topspeed - Internet Connect]
Allerup Edb
Denmark

http://www.icetips.com
UIN nr.: 2428601



Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

The 32 bits function GetVersionEx returns a pointer to the OSINFOVERSION
data structure.
Try something like this:
(I've not testet the example below. I just put it together in a hurry.)

    MAP
      MODULE('Win API 32')
        GetVersionEx(*GROUP),LONG,RAW,PASCAL
      END
    END

OsVersionInfo       GROUP
dwOSVersionInfoSize   ULONG
dwMajorVersion        ULONG
dwMinorVersion        ULONG
dwBuildNumber         ULONG
dwPlatformId          ULONG
szCSDVersion          CSTRING(128)
                    END

  CODE
  dwOSVersionInfoSize = 148
  IF GetVersionEX(OsVersionInfo) = 0
    MESSAGE('GetVersionEx failed','Error')
  END

The data in the OsVersionInfo group:
--  dwOSVersionInfoSize  --
Specifies the size, in bytes, of this data structure. Set this member to
sizeof(OSVERSIONINFO) before calling the GetVersionEx function.
--  dwMajorVersion  --
Identifies the major version number of the operating system. For example,
for Windows NT version 3.51, the major version number is 3; and for Windows
NT version 4.0, the major version number is 4.
--  dwMinorVersion  --
Identifies the minor version number of the operating system. For example,
for Windows NT version 3.51, the minor version number is 51; and for Windows
NT version 4.0, the minor version number is 0.
--  dwBuildNumber  --
Windows NT: Identifies the build number of the operating system.
Windows 95: Identifies the build number of the operating system in the
low-order word. The high-order word contains the major and minor version
numbers.
--  dwPlatformId  --
Identifies the operating system platform. This member can be one of the
following values: Value Platform
VER_PLATFORM_WIN32s Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95 or Windows 98.
For Windows 95, dwMinorVersion is 0.
For Windows 98, dwMinorVersion is 10.
VER_PLATFORM_WIN32_NT Win32 on Windows NT.
--  szCSDVersion  --
Windows NT: Contains a null-terminated string, such as "Service Pack 3",
that indicates the latest Service Pack installed on the system. If no
Service Pack has been installed, the string is empty.
Windows 95: Contains a null-terminated string that provides arbitrary
additional information about the operating system.

HTH
Geir Hansen
Nordic Innovator AS

Quote:

>Any ideas why the 32bit version would fail?



Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

OOPS - a little typo:
It doesn't return the pointer. You pass the pointer! It returns an interger
<> 0 if it succeed.

Geir Hansen
Nordic Innovator AS

Quote:

>The 32 bits function GetVersionEx returns a pointer to the OSINFOVERSION



Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Geir,

On Sat, 6 Jun 1998 21:51:36 +0200, "Geir Hansen"

Quote:

>  dwOSVersionInfoSize = 148

That's most likely my problem.  Didn't RTFM<g>  I assumed it was a
returned value, not passed value.  BTW:  I'd rather use Size(...) here
- makes the code more flexible:)

Best regards,

Arnor Baldvinsson        
[Team Topspeed - Internet Connect]
Allerup Edb
Denmark

http://www.icetips.com
UIN nr.: 2428601



Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Geir,
What's even more frustrating is when you hit search on the MS website, come up
with 10 references or so and each one comes back with a 404 server error, like
I did today:(. Most of the ASP pages didn't seem to be working in their KB.

Quote:

> Hi Arnor,

> Yes, the MS Windows API documentation really deserves to be called a FM
> (F...ing Manual). You almost need to be a CMDD (Certified Microsoft
> Documentation Detective <g>) to use it. Even for a CMDD, the documentation
> can hardly be called a RSL (Rapid Syntax Lookup) tool either.
> AHA - that's why they call these things API Bibles: "Search, and you shall
> find!"
> Search once to find a usable function. Search again to find the definition
> of the data structure used by the function. Search again to find the
> definition of the first constant/equate in the data structure. Search again
> ..., and again ..., and again...

> Geir Hansen
> Nordic Innovator AS

> Arnor Baldvinsson wrote
> >That's most likely my problem.  Didn't RTFM<g>

--
Jim Katz
CTO iTradeZone,Inc.
http://www.iag.net/~jimkatz/
ICQ 9891427
Using Clarion for Windows
Always looking for the simpler solution.


Wed, 22 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Arnor,

Yes, the MS Windows API documentation really deserves to be called a FM
(F...ing Manual). You almost need to be a CMDD (Certified Microsoft
Documentation Detective <g>) to use it. Even for a CMDD, the documentation
can hardly be called a RSL (Rapid Syntax Lookup) tool either.
AHA - that's why they call these things API Bibles: "Search, and you shall
find!"
Search once to find a usable function. Search again to find the definition
of the data structure used by the function. Search again to find the
definition of the first constant/equate in the data structure. Search again
..., and again ..., and again...

Geir Hansen
Nordic Innovator AS

Arnor Baldvinsson wrote

Quote:
>That's most likely my problem.  Didn't RTFM<g>



Thu, 23 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

I have the stuff (MS Developer Network Library) on my HD. The searches work
OK, it's just frustrating that you have to search on so many different
things to figure out all you need for a single function. Even though I
complain about the quality (structure actually) of the documentation, I
could not live without it. Besides all the documentation and information,
you get a very useful set of utilities. Accessing the MS web site each time
I need to lookup something, is just not an option I would even consider.

Geir Hansen
Nordic Innovator AS

Quote:

>What's even more frustrating is when you hit search on the MS website, come
up
>with 10 references or so and each one comes back with a 404 server error,
like
>I did today:(. Most of the ASP pages didn't seem to be working in their KB.



Thu, 23 Nov 2000 03:00:00 GMT  
 Detecting 16bit or 32bit OS

Hi Geir,

On Sun, 7 Jun 1998 04:32:59 +0200, "Geir Hansen"

Quote:

>Yes, the MS Windows API documentation really deserves to be called a FM
>(F...ing Manual). You almost need to be a CMDD (Certified Microsoft
>Documentation Detective <g>) to use it. Even for a CMDD, the documentation
>can hardly be called a RSL (Rapid Syntax Lookup) tool either.
>AHA - that's why they call these things API Bibles: "Search, and you shall
>find!"
>Search once to find a usable function. Search again to find the definition
>of the data structure used by the function. Search again to find the
>definition of the first constant/equate in the data structure. Search again
>..., and again ..., and again...

Well, I don't have any "hard" docs on Win32 api, only the 32bit api
help file.  It has links to the structures, so it's fairly easy to
find things there, but it has no information about constants, but then
most of these are in the winapi from TS.  

Best regards,

Arnor Baldvinsson        
[Team Topspeed - Internet Connect]
Allerup Edb
Denmark

http://www.icetips.com
UIN nr.: 2428601



Thu, 23 Nov 2000 03:00:00 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Problem: Changing from 16bit to 32bit

2. Going from 16bit to 32bit

3. 16bit to 32bit conversion

4. 32bit runtime errors - 16bit runs fim

5. 32bit vs 16bit

6. Help: 16bit or 32bit-dll

7. Clarion - 32bit application slower than 16bit

8. 32bit menu vs 16bit

9. SecWin 16bit & 32bit

10. 32bit application slower than 16bit

11. Database Drivers 16bit or 32bit

 

 
Powered by phpBB® Forum Software