Previous Topic Next topic Print topic


Example of Calling a Win32 API Routine

Restriction: The following applies to native COBOL only.

The following program makes use of an API routine to retrieve the current date and time.

 special-names.
     call-convention 74 is winapi.
 working-storage section. 
 01 system-time.
     03 system-year     pic 9(4) comp-5.
     03 system-month    pic 9(4) comp-5.
     03 system-day-of-week  pic 9(4) comp-5.
     03 system-day    pic 9(4) comp-5.
     03 system-hour    pic 9(4) comp-5.
     03 system-minute   pic 9(4) comp-5.
     03 system-second   pic 9(4) comp-5.
     03 system-millisecond  pic 9(4) comp-5.

 procedure division.
     call winapi "GetSystemTime" using
                  by reference system-time
     display "Day of week is:  " system-day-of-week
     display "Day of month is:  " system-day
     stop run.
Previous Topic Next topic Print topic