DOCERR: Win32 APIs Callable from a QuickWin Application

Last reviewed: December 9, 1995
Article ID: Q118814
The information in this article applies to:
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 4.0

SUMMARY

On page 166 of the PowerStation 32 "Programmer's Guide," the first paragraph implies that you cannot call Win32 APIs from a QuickWin application; however, you actually can call Win32 APIs that do not require a window handle.

MORE INFORMATION

To call a Win32 API, you must create a proper INTERFACE TO statement and link with the proper import library.

You can determine the proper INTERFACE TO statement by reading the "Win32 Programmer's Reference". The STDCALL attribute is required for the function declaration.

The sample code below calls the MessageBox() API, contained in the import library, USER32.LIB, which is already linked into the program for a QuickWin application by default. The first parameter of MessageBox() is a window handle or 0 (NULL). You must use 0, because the window handle is not available in a QuickWin application.

NOTE: When you pass a string to an API, make sure that you use the C convention, so that the string is NULL terminated. See page 53 of the "Programmer's Guide" for a discussion of C strings.

Sample Code

C Compile options needed: /MW

      INTERFACE TO FUNCTION
     +MESSAGEBOX  (hwnd, text, title, icon)
      INTEGER*4 MESSAGEBOX [STDCALL, ALIAS:'_MessageBoxA@16']
      INTEGER*4 hwnd [VALUE]
      CHARACTER*(*) text [REFERENCE]
      CHARACTER*(*) title [REFERENCE]
      INTEGER*4 icon [VALUE]
      END

      CHARACTER text*34, title*21

      text = 'This API was called from FORTRAN.'C
      title = 'QuickWin Application'C

      PRINT*, "Enter any character to continue: "
      READ(*, '(A)')

      i = MESSAGEBOX(0, text, title, 1)

      PRINT*, "MessageBox called"

      END


Additional reference words: 1.00 4.00 docerr
KBCategory: kbprg kbdocerr
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 9, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.