Problem:
Release: 3.1
The following is a correct example of calling the "GlobalAlloc" function.
Resolution:
The following code is a sample that works correctly using .int code.
id division.
program-id. testalloc.
environment division.
special-names.
call-convention 74 is winapi.
data division.
working-storage section.
78 GMEM-FIXED value h"0000".
78 GMEM-MOVEABLE value h"0002".
78 GMEM-SHARE value h"2000".
01 alloc-flags pic 9(9) comp-5 value zeroes.
01 memory-handle pic s9(9) comp-5 value zeroes.
01 ret-code pic s9(9) comp-5 value zeroes.
procedure division.
000-begin.
call "cob32api"
move GMEM-MOVEABLE to alloc-flags
add GMEM-SHARE to alloc-flags
call winapi "GlobalAlloc"
using by value alloc-flags
by value 1024
returning memory-handle
end-call
if memory-handle = 0
display "GlobalAlloc failed"
else
call winapi "GlobalSize"
using by value memory-handle
returning ret-code
end-call
if ret-code = 0
call winapi "GetLastError" returning ret-code
display "Error on GlobalSize = " ret-code
end-if
call winapi "GlobalFree"
using by value memory-handle
end-call
end-if
stop run.