Problem:
This article provides instruction and a demonstration regarding how one can detect when a program developed with Net Express with .NET 4.0 is running under the control of the CLR (.NET Common Language Runtime).
Resolution:
Functionally, the method of detection involves two steps:
1.
use the MF function CBL_GET_OS_INFO
2.
look at the bit 5 of cblte-osi-rts-capabilities
When = 1, it means that the program is running under the control of the CLR
The demo program showing how this is used follows.
Note: To run this demo, the latest update (ALL04N40.exe) needs to be installed in the Net Express 4.0 product.
$SET SOURCEFORMAT"FREE"
program-id. CLRprogOrNot as "CLRprogOrNot".
environment division.
configuration section.
repository.
data division.
working-storage section.
01 parameter-block .
02 cblte-osi-length pic x(2) comp-x value 18.
02 cblte-osi-os-type pic x comp-x.
02 cblte-osi-os-version pic x(4) comp-x.
02 cblte-osi-dbcs-support pic x comp-x.
02 cblte-osi-char-coding pic x comp-x.
02 cblte-osi-country-id pic x(2) comp-x.
02 cblte-osi-code-page pic x(2) comp-x.
02 cblte-osi-process-type pic x comp-x.
02 cblte-osi-rts-capabilities pic x(4) comp-x.
02 cblte-osi-reserved pic x occurs 5.
01 status-code pic x(4) comp-5.
01 osv pic x.
01 OsvX redefines osv pic x comp-x.
01 osvN pic 99.
01 rts-cap pic x comp-x.
01 .
03 Array-group pic x(8) comp-x value h"0".
03 Array redefines Array-group
pic x comp-x occurs 8.
procedure division.
call "CBL_GET_OS_INFO" using parameter-block
returning status-code
end-call
if status-code = 0
evaluate cblte-osi-os-type
when 131 display "Windows systems"
when 128 display "COBOL system on UNIX"
end-evaluate
* * display cblte-osi-os-version
if cblte-osi-os-type = 131 *> Windows systems
move cblte-osi-os-version(3:1) to osv
move osvX to osvN
display "OS minor version: " osvN
move cblte-osi-os-version(4:1) to osv
move osvX to osvN
display "OS major version: " osvN
end-if
evaluate cblte-osi-dbcs-support
when 0 *> binary 00
when 2 *> binary 10
display "DBCS validation unsupported"
when 1 *> binary 01
when 3 *> binary 11
display "DBCS validation supported"
end-evaluate
evaluate cblte-osi-dbcs-support
when 2 *> binary 10
when 0 *> binary 00
display "PIC N data-type unsupported"
when 3 *> binary 11
display "PIC N data-type supported"
end-evaluate
display "Character encoding " cblte-osi-char-coding
evaluate cblte-osi-char-coding
when 0 display " Character encoding: 0 ASCII"
when 1 display " Shift-JIS "
when 2 display " EUC Japan "
when 3 display " BIG-5 (Traditional Chinese) "
when 4 display " 5550 (Traditional Chinese) "
when 5 display " GB (Simplified Chinese) "
when 6 display " KS-CODE (Korean) "
when 7 display " PC-CODE (Korean) "
when 8 display " EUC Taiwan "
when 9 display " EUC locales "
end-evaluate
display "Country code: " cblte-osi-country-id
display "code-page: " cblte-osi-code-page
display "Process type: " with no advancing
evaluate cblte-osi-process-type
when 0 display " 0 Process is running in a full screen session "
when 3 display " 3 Process is running as a true graphical application "
end-evaluate
display "Characteristics of run-time system"
move cblte-osi-rts-capabilities to rts-cap
Call x"F5" using rts-cap Array-group
evaluate array(8)
when 1 display " Multithreaded rts"
when 0 display " Monothreaded rts"
end-evaluate
evaluate array(7)
when 1 display " Mainframe offloading capabilities"
when 0 display " NO Mainframe offloading capabilities"
end-evaluate
evaluate array(6)
when 1 display " 64-bit capability; the run-time system is running on a 64-bit operating system"
when 0 display " 32-bit capability; the run-time system is running on a 32-bit operating system"
end-evaluate
evaluate array(5)
when 1 display " the program is running under the control of Enterprise Server"
when 0 display " the program is NOT the program is running under the control of Enterprise Server"
end-evaluate
evaluate array(4)
when 1 display " the program is running in Enterprise Server mode"
when 0 display " the program is NOT running in Enterprise Server mode"
end-evaluate
evaluate array(3)
when 1 display " the program is running under the control of the CLR"
when 0 display " the program is NOT running under the control of the CLR "
end-evaluate
goback.
end program CLRprogOrNot.
