Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Calling Windows API from managed COBOL

$
0
0

Actually, the problem with the Windows.cpy is that it is using a few data-names that are now COBOL reserved words.

This can be remedied so that you can use Windows.cpy in managed code by removing these as reserved words using the remove directive.

The following example will allow you to use windows.cpy in your .NET programs:

      $set ilpinvoke"kernel32"
      $if ilgen set
      $set remove"byte"
      $set remove"event"
      $set remove"internal"
      $set  change-message"1202 N"
      $set  change-message"1207 N"
      $set  change-message"1122 N"
      $end
       copy "windows.cpy".
      $if ilgen set
      $set  change-message"1202 W"
      $set  change-message"1207 W"
      $set  change-message"1122 W"
      $end
       
       program-id.  testapi.
       environment division.
       special-names.
       call-convention 74 is WAPI.

       working-storage section.
       01 VersionInfoEx.
          03 dwEVersionInfoSize        pic 9(9) comp-5.
          03 dwEMajorVersion           DWORD.
          03 dwEMinorVersion           DWORD.
          03 dwEBuildNumberFull.
             05 dwEBuildNumber         USHORT.
             05 dwEMajorAndMinor       USHORT.
          03 dwEPlatformId             DWORD.
          03 szECSDVersion             pic x(128).
          03 wEServicePackMajor        WORD.
          03 wEServicePackMinor        WORD.
          03 wESuiteMask               WORD.
          03 wEProduktType             BYTE.
             88 ver-nt-workstation        value h"01".
             88 ver-nt-server             value h"02" h"03".
             88 ver-nt-domain-controller  value h"02".
          03 wEReserved                BYTE.
       procedure division.
          set dwEVersionInfoSize to length of VersionInfoEx
          call WAPI "GetVersionExA" using VersionInfoEx
          goback.
           
       

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>