Highlighted
Absent Member.
Absent Member.
1670 views

Has anyone tried calling Windows API "shell32.dll" "ShellExecuteA" from within Cobol, I keep getting memory access violation ??

Here is a snippet of the code, I can open the .dll, however when I try to run the ShellExecuteA is where I get the error, I found this string in the API Guide:

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Here is what is in the wb-1-url

           initialize wb-1-url.
SSRS       MOVE "168.93.99.58/.../ReportViewer.asp
SSRS  -         "x?%2fTEST+REPORTS%2fTEST&rs:Command=Render&VendorNumber
SSRS  -         "Start=001100&VendorNumberEnd=00UY7&rc:Parameters=Collap
SSRS  -         "sed"
SSRS           TO wb-1-url.
           inspect wb-1-url replacing trailing spaces by low-values.

 

       call-ssrs2.

           perform GET-SYSTEM-VARIABLES.


           SET     ENVIRONMENT      "DLL-CONVENTION" TO 1.

           STRING SYSTEM-ROOT      DELIMITED BY LOW-VALUES
                  "shell32.dll"     DELIMITED BY SIZE
                  INTO SYSTEM-ENV.

           CALL    SYSTEM-ENV
                   ON EXCEPTION     GO TO ERR-CALL.

           CALL    "ShellExecuteA"  USING
                   by value 0 size 4
                   by reference "open"
                   by reference
                      WB-1-URL
                   by value 0 size 4
                   by reference "C:\"
                   by value SW-SHOWALL
                   ON EXCEPTION     GO TO ERR-CALL.
           CANCEL  "shell32.dll".
           EXIT    PROGRAM.

       GET-SYSTEM-VARIABLES.

           ACCEPT TERMINAL-ABILITIES FROM TERMINAL-INFO.

           ACCEPT SYSTEM-INFORMATION FROM SYSTEM-INFO.

      *Make sure we are synchronized with the DLL.

           SET     ENVIRONMENT      "DLL-CONVENTION" TO "WINAPI".

      *Load the DLL that hosts the functions. We terminate here
      *if the load fails, as there is no need to clean up
      *anything at this point of execution.

           INITIALIZE SYSTEM-ENV,
                      SYSTEM-LOCATION,
                      SYSTEM-ROOT,
                      SYSTEM-CALL,
                      SYSTEM-CALL-STATUS.

           ACCEPT SYSTEM-ROOT FROM ENVIRONMENT "WINDOWSDIRLOCATION".

           INSPECT SYSTEM-ROOT REPLACING TRAILING SPACES BY LOW-VALUES.


0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Has anyone tried calling Windows API "shell32.dll" "ShellExecuteA" from within Cobol, I keep getting memory access violation ??

Not an expert, but if you look at this forum article: community.microfocus.com/.../calling-web-browser-from-thin-client you'll see that the open command needs to be terminated
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Has anyone tried calling Windows API "shell32.dll" "ShellExecuteA" from within Cobol, I keep getting memory access violation ??

Thank you, yes this did work, I still have to test out thin client, we now have a means of launching an SSRS report with stored procedures that transforms legacy Cobol reports to elaborate Graphical styled reports.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Has anyone tried calling Windows API "shell32.dll" "ShellExecuteA" from within Cobol, I keep getting memory access violation ??

Great, like the forum article, add the @DISPLAY syntax so that the call happens on the client
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.