Microsoft KB Archive/99336

{|
 * width="100%"|

PRB: Combined Windows 3.0 and 3.1 Applications

 * }

Q99336

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK) 3.0

-

When a combined Windows 3.0 and 3.1 application is run under the debugging version of Windows 3.0, during load time, a Fatal Exit message &quot;Invalid Ordinal Reference&quot; is displayed on the debug terminal followed by a stack trace.

Note, however, that the application continues to load and run successfully, and therefore this error message can be ignored as long as the Windows 3.1 function is not actually called.

CAUSE
While loading an application, the Windows 3.0 kernel attempts to fix up references to all function calls in the application. At load time, the Windows 3.0 kernel is unaware of the version checking being done on the Windows 3.1-specific calls. The version 3.0 kernel will attempt to fix up the references to the Windows 3.1 calls too, which are undefined, and therefore the Fatal Exit message is generated.

RESOLUTION
The Fatal Exit message can be ignored because the application will run successfully.

If this behavior (the Fatal Exit message) is not satisfactory, use the following workaround to call Windows 3.1-specific calls in a Windows 3.0 application without generating any Fatal Exit messages:

extern BOOL fWin31; // Assuming fWin31 is initialized appropriately using GetVersion.

if (fWin31) {         // Get the address of the Window 3.1-specific function.

// First, load either USER.EXE, GDI.EXE, or KERNEL.EXE, // depending on which DLL the function resides in. LoadLibrary(...);

// Get the address of that function using GetProcAddress. lpfnWin31FuncAddr = GetProcAddress(...);

// Use this address to make the function call. (*lpfnWin31FuncAddr)(...); } This method will not generate a Fatal Exit message under the debug version of Windows 3.0, because there is no direct reference made to a Windows 3.1 function.

For a quick reference on how this method works, please see the DIBVIEW sample provided with the Windows SDK. The source file PRINT.C adopts this same technique in the FindGDIFunction routine before calling any GDI functions specific to Windows 3.1.

MORE INFORMATION
Microsoft Windows version 3.0 applications can be written to conditionally link to and use Windows version 3.1 functions to take advantage of the newer features when running under Windows 3.1. This is explained in the &quot;Combined Windows 3.0 and 3.1 Applications&quot; section on page 31 of the Microsoft Windows SDK &quot;Getting Started&quot; manual for version 3.1.

This behavior may not be suitable for certain applications or could lead to other problems. For example, on systems that do not have a debug terminal connected to the COM1 port to receive debug information, Kernel will display a &quot;Cannot write to device AUX&quot; message box or the system might freeze. The debug message could be redirected from the AUX device to some other destination, if desired. For information on how to do this, please query on the following words in the Microsoft Knowledge Base:

"redirect debug information" Additional query words: 3.10 RIP

Keywords : kb16bitonly

Issue type :

Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK300