DosPutMessage is used to write the message to the screen or to a file on a disk.

The following code fragment writes the message string contained in MessageBuffer to the file specified by FileHandle. The message string has already been placed in MessageBuffer using either DosGetMessage or DosInsertMessage. MsgLength was set to the length of the message string by the same call that put the message into MessageBuffer.

    #define INCL_DOSMISC   /* Miscellaneous values */
    #include <os2.h>
    #include <stdio.h>


    HFILE   hfFileHandle;           /* Handle of output file or device */
    ULONG   ulMsgLength;            /* Length of message buffer        */
    UCHAR   ucMessageBuffer[80];    /* Message buffer                  */
    APIRET  ulrc;                   /* Return code                     */

    ulrc = DosPutMessage(hfFileHandle,
                         ulMsgLength,
                         ucMessageBuffer);

    if (ulrc != 0) {
        printf("DosPutMessage error: return code = %ld",
               ulrc);
        return;
    }

To write a message to the screen, use the standard output file handle.


[Back] [Next]