Skip to main content

Hi,

We use OLE methodology to invoke server objects like VB modules to perform print operation. I would like to know if there's any way to invoke a URL from cobol program.

For suppose invoke "www.google.com" from cobol program.

Appreciate your help. Thank you.

Hi,

We use OLE methodology to invoke server objects like VB modules to perform print operation. I would like to know if there's any way to invoke a URL from cobol program.

For suppose invoke "www.google.com" from cobol program.

Appreciate your help. Thank you.

Hi,

I have attached a code sample showing how you can use the WinHTTP COM objects from Net Express (or Visual COBOL).

There is an HTTP GET and HTTP POST example.

Regards

David


Hi,

We use OLE methodology to invoke server objects like VB modules to perform print operation. I would like to know if there's any way to invoke a URL from cobol program.

For suppose invoke "www.google.com" from cobol program.

Appreciate your help. Thank you.

I think that...

     $set mfoo case remove(beep) remove(escape)

     *-----------------------------------------------------------------*

     * Modulo : cblSExec                                               *

     * Funcao : Exemplo de utilização da API ShellExecute, baseado em  *

     *          exemplo em VB que se encontra no APIGuide.             *

     *                                                                 *

     *Declaração da Função em VB:                                      *

     *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                     *

     *                                                                 *

     * Mais informações sobre a função no final deste arquivo.         *

     *                                                                 *

     * Pede-se a gentileza de, caso alguém venha a alterar/incluir     *

     * alguma função, enviar a mesma para ajsauro@gmail.com            *

     *                                                                 *

     *-----------------------------------------------------------------*

     * Se este código não funcionar, não faço idéia de quem o escreveu,*

     * mas se funcionar, ele foi escrito por:                          *

     *                                                                 *

     *                             /"""\\                               *

     *                            ( o o )                              *

     *   .--------------------oOOO--(_)--OOOo--------------------.     *

     *   | Antonio João                                   ajSauro|     *

     *   | ajsauro@gmail.com                                     |     *

     *   |-------------------------------------------------------|     *

     *   | Primavera do Leste                 Diga não às drogas.|     *

     *   | Mato Grosso         .oooO          Não ouça pagode!   |     *

     *   | Brasil              (   )   Oooo.  Não ouça sertanojo!|     *

     *   `----------------------\\ (----(   )---------------------´     *

     *                           \\_)    ) /                            *

     *                                 (_/                             *

     *-----------------------------------------------------------------*

     *******************************************************************

      IDENTIFICATION         DIVISION.

     *******************************************************************

      PROGRAM-ID.  cblSExec.

     *******************************************************************

      ENVIRONMENT            DIVISION.

     *******************************************************************

     *------------------------------

      CONFIGURATION          SECTION.

     *------------------------------

      SPECIAL-NAMES.         Decimal-Point is Comma

                             Call-Convention 74 is WINAPI

                             .

     *------------------------------

      INPUT-OUTPUT           SECTION.

     *------------------------------

      FILE-CONTROL.

     *------------

     *******************************************************************

      DATA                   DIVISION.

     *******************************************************************

     *------------------------------

      FILE                   SECTION.

     *------------------------------

     *------------------------------

      WORKING-STORAGE        SECTION.

     *------------------------------

      77           bool                pic s9(009) comp-5 is typedef.

      77           Program-Name        PIC X(008) VALUE "cblSExec".

     *

      78           DialogSystem        Value "dsgrun".

      78           cblNullString       VALUE X"00".

     * Você encontrará a definição destas constantes em WINDOWS.CPY

      78           SW-SHOWNORMAL       value 1.

      78           SW-SHOWMINIMIZED    value 2.

      78           SW-SHOWMAXIMIZED    value 3.

     *

      01           lsBool              bool.

      01           This-Program-Name   PIC X(012) VALUE "cblSExec".

      01           Program-Flags       PIC 9(2) COMP-5 VALUE 1.

        88         New-Instance        VALUE 1 FALSE 0.

     *

      01 DATA-BLOCK.

         03 WINDOW-HANDLE                   PIC x(4) COMP-5 value 0.

         03 OPERACAO                        PIC X(22).

     *

         03 DOPERATION                      PIC X(7).

         03 DSEXECPARAM.

            05 DFLAG                        PIC X(7).

            05 DQUERY                       PIC X(194).

     *******************************************************************

      procedure              division.

     *******************************************************************

     *------------------------------

      000-000-INICIO         Section.

     *------------------------------

          Perform  New-Set-Instance

          Perform  Abrir-WExplorer

          Perform  Abrir-IExplorer

          Perform  Program-Terminate

          Stop     Run

          .

      000-000-FINAL.

     *------------------------------

      Abrir-WExplorer        Section.

     *------------------------------

     *Abrir o Windows Explorer na pasta C:\\Temp

          call     Winapi "ShellExecuteA" using

                                    by value Window-Handle

                                by Reference z"Open"

                                by Reference z"Explorer.exe"

                                by Reference z"C:\\Temp\\"

                                by Reference cblNullString

                                    by value SW-SHOWNORMAL

                                   returning lsBool

          .

      Abrir-IExplorer        Section.

     *------------------------------

     *Abrir o Internet Explorer em ajsauro.blogspot.com

          call     Winapi "ShellExecuteA" using

                                    by value Window-Handle             *>hwnd

                                by Reference dOperation                *>lpOperation

                                by Reference dSExecParam               *>lpFile

                                by Reference cblNullString             *>lpParameters

                                by Reference z"C:\\"                    *>lpDirectory

                                    by value SW-SHOWNORMAL             *>nShowCmd

                                   returning lsBool                    *>Return value

          .

      New-Set-Instance       Section.

          CALL     'COB32API'

          MOVE     z"Open"             to dOPERATION

          MOVE     "http://"           to dFLAG

          MOVE

          z"ajsauro.blogspot.com.br/2014/03/campo-minado-em-cobol.html"

                                       to dQUERY

          .

      Program-Terminate      Section.

     *-----------------

          Cancel   'COB32API'

          Move     "Zé Endi"           to dOperation

          .

     *******************************************************************


Hi,

We use OLE methodology to invoke server objects like VB modules to perform print operation. I would like to know if there's any way to invoke a URL from cobol program.

For suppose invoke "www.google.com" from cobol program.

Appreciate your help. Thank you.

Also see the simple example in the kb article here: