QCW9204002: _osmajor and _osminor Report Windows Version

ID Number: Q83079

1.00

WINDOWS

buglist1.00

Summary:

PROBLEM ID: QCW9204002

SYMPTOMS

When using the Microsoft QuickC for Windows (QC/Win) Graphical

Development Environment version 1.0, using _osmajor and _osminor

within an application for Windows or a QuickWin application will

return the version of Windows rather than the version of MS-DOS.

RESOLUTION

To work around this problem, obtain the MS-DOS version by using the

MS-DOS interrupt 21H function 30H call.

For an executable for Windows or a QuickWin application, an MS-DOS

interrupt can be called with the Windows API function DOS3Call.

To obtain the MS-DOS version using DOS3Call, do the following:

1. Include the header file STDLIB.H in the source code. Remember

that WINDOWS.H must precede all other header files. Do not

include WINDOWS.H for a QuickWin application.

2. Declare the DOS3Call function in the beginning of the source

code after the #include statements. This function is defined in

KERNEL.EXE included with Windows. Use the following declaration:

void _pascal _far DOS3Call(void);

3. Use DOS3Call to make the MS-DOS interrupt 21h function 30h call

within the source code of the executable for Windows. DOS3Call

must be called from an assembly code block in QC/Win. In the

source code that initializes the application, use the following

code fragment:

_asm

{

mov ah,30h ; function 30h get the DOS version

mov al,0 ;

call DOS3Call ; do the call

mov _osmajor,al ; al has the major number

mov _osminor,ah ; ah has the minor number

}

The variables _osmajor and _osminor can now be used as suggested in

the online help for QC/Win.

Note: This method is in addition to the preferred method described

on page 256 of the "Microsoft QuickC for Windows: Windows

Programming Reference."

STATUS

Microsoft has confirmed this to be a problem in QuickC for Windows

version 1.0. We are researching this problem and will post new

information here as it becomes available.

More Information:

The following code illustrates the problem when built as a QuickWin

.EXE, and also demonstrates how to work around the problem.

Note: Using the Microsoft Windows Software Development Kit (SDK) to

create a Windows application does not produce this error.

Sample Code

-----------

/* Compile options needed: Must be compiled as a QuickWin .EXE

*/

#include <stdio.h>

#include <stdlib.h>

void _pascal _far DOS3Call(void);

void main(void)

{

printf("_osmajor and _osminor used to get version of DOS: "

"%d.%d\n\n",_osmajor, _osminor);

_asm

{

mov ah,30h ; function 30h get the DOS version

mov al,0 ;

call DOS3Call ; do the call

mov _osmajor,al ; al has the major number

mov _osminor,ah ; ah has the minor number

}

printf("After the DOS3Call\n\n");

printf("_osmajor and _osminor used to get version of DOS: "

"%d.%d\n\n",_osmajor, _osminor);

}

Additional reference words: qcwin quick qcw