DOCERR: Win32 APIs Callable from a QuickWin ApplicationLast reviewed: December 9, 1995Article ID: Q118814 |
The information in this article applies to:
SUMMARYOn 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 INFORMATIONTo 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 CodeC 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |