Hi there,
Hoping someone can help.
I'm calling winapi "ShellExecuteA" from a Visual Cobol program to open a document (pdf/webpage etc) which works fine. It returns a handle instance, 'hinstance' which I need to check for errors How can I move it to a field I can examine?
Windows documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx) says...
"Return value - Type: HINSTANCE - If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below."
MY PROGRAM
$set ooctrl(+P)
copy "windows.cpy".
IDENTIFICATION DIVISION.
special-names.
call-convention 74 is winapi. *> Litlinked apis
WORKING-STORAGE SECTION.
01 sw-cwd pic x(1024).
01 se-hInstance HINSTANCE.
01 msgBoxText pic x(255).
LINKAGE SECTION.
01 fileToLaunch pic x(256).
PROCEDURE DIVISION using fileToLaunch.
call "cob32api".
call winapi "ShellExecuteA" using
by value 0 size 4
by reference z"open"
by reference fileToLaunch
by value 0 size 4,
by reference sw-cwd
by value SW-SHOWNORMAL
returning se-hInstance
end-call.
IF SE-HINSTANCE <= 32 *> !!!!! ILLEGAL POINTER USAGE - HOW TO DO THIS ?????
initialize msgBoxText
string "Unable to open the document (most likely doesn't"
" exist or could already be in use. File name:"
fileToLaunch
delimited by x'00' into msgBoxText
call "messageBox" using msgBoxText
end-if.
goback.
THANK YOU,
Linden