How to tell the difference between Windows 3.1 and 95, Please help 
Author Message
 How to tell the difference between Windows 3.1 and 95, Please help

In Visual Basic how Can I have my program know which OS it is running on?

For Instance:

If win3.1 then
  Do this
else if win95 then
 Do this
End if

Please help thanks..




Mon, 27 Sep 1999 03:00:00 GMT  
 How to tell the difference between Windows 3.1 and 95, Please help

Quote:

>In Visual Basic how Can I have my program know which OS it is running on?
>For Instance:
>If win3.1 then
>  Do this
>else if win95 then
> Do this
>End if
>Please help thanks..


Hi Robert,
look for conditional compilation in the VB manuals.
You have to write one code for both. Only that code, that differs, you
have to write between the "#IF - #THEN - #ELSE". You have to compile
twice (under WIN3.1 and under WIN95).

Example:
#If Win16 Then
    API16...
#Else
    API32...
#End If

Gerhard Amberger, Germany



Wed, 29 Sep 1999 03:00:00 GMT  
 How to tell the difference between Windows 3.1 and 95, Please help

The following recommendation will require multiple executables for each
version you wish to address, and I don't think you want to take this
approach.  That is what you are trying to avoid!



Quote:

> >In Visual Basic how Can I have my program know which OS it is running
on?

> >For Instance:

> >If win3.1 then
> >  Do this
> >else if win95 then
> > Do this
> >End if

> >Please help thanks..


> Hi Robert,
> look for conditional compilation in the VB manuals.
> You have to write one code for both. Only that code, that differs, you
> have to write between the "#IF - #THEN - #ELSE". You have to compile
> twice (under WIN3.1 and under WIN95).

> Example:
> #If Win16 Then
>     API16...
> #Else
>     API32...
> #End If

> Gerhard Amberger, Germany

Instead ...
***********************
From Win31wh.hlp:

DWORD GetVersion(void)

The GetVersion function retrieves the current version numbers of the
Windows and MS-DOS operation systems.
Returns

The return value specifies the major and minor version numbers of Windows
and of MS-DOS.

Comments

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.
***********************

Now in VB, you would say something like:

dim lVersion as long
dim iWinVer  as integer
dim iDosVer  as integer

  lVersion = GetVersion()
  ' Since there is no bit extraction in VB, you have to do
  ' the math to get the high-order and low-order 16-bit words.
  iWinVer = lVersion Mod 65536
  iDosVer = lVersion \ 65536

  ' Use the same approach to get the high-order and low-order bytes.
  msgbox "Windows version " & iWinVer mod 256 & "." & iWinVer \ 256
  msgbox "Dos version " & iDosVer \ 256 & "." & iDosVer mod 256

Lastly you have to declare the GetVersion call

Declare Function GetVersion Lib "Kernel" () As Long

Good luck!
--
Kevin Nechodom
NurseWare



Tue, 05 Oct 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Newbie: VB4, Windows 95 platform, Windows 3.1 target

2. Compile under Windows 3.1 different from compile under Windows 95

3. Sound differences between Win 3.1 and Win 95

4. Maintain Application for Windows 3.1 and 95

5. Disabling Ctrl-Alt-Del in Windows 3.1/95

6. Restarting Windows 3.1, 95?

7. Shutdown windows (3.1 / 3.11 / 95)

8. Shutdown windows 3.1 / 3.11 / 95

9. differences between Windows 95 and NT GDI32.DLL

10. Returning Windows version on 3.10, 3.11, 95 and NT

11. Windows NT/2000 and 95/98 shell32.dll difference

12. Netware 3.1 , Windows 3.1 and VB

 

 
Powered by phpBB® Forum Software