Skip to main content

Problem:

Using Win 32 API to create a new process in COBOL

Resolution:

INTRODUCTION

==========

This example demonstrates the use of the Win32 API function call CreateProcess in order to execute a non-COBOL program from within a COBOL program. In this example, the Windows Text Editor NOTEPAD.EXE will be executed. The program will then wait until NOTEPAD has been exited at which point it will also exit.

CreateProcess allows you to control how a program is started along with the parameters the environment and the working directory that the new program should use.

SOURCE FILES:

==========

Program Files          Description

--------------------     -----------------------------------------------------------

CREATEP.CBL         Program that calls the CreateProcess function.

WINTYPES.CPY       Copy file containing the converted Win32 typedefs so they can be used in

                                COBOL.

MINIWIN.CPY         Copy file containing the Win32 API entry point names and environment

                                constants.

WINBASE.CPY        Copy file containing the converted definitions of various Win32 API constants.

WINUSER.CPY        Copy file containing the converted definitions of various Win32 API messages.

CREATEP.TXT         The text file loaded into NOTEPAD.EXE.

REQUIREMENTS:

==========

This sample should run in all environments.

OPERATION:

========

Rebuild this project to create the file createp.exe. This is a character mode program that will display its progress to an application output window.

==========================================================

Keywords: demonstration, sample, example, demo, win32 api, createp.zip

demo.ex

demo.ne

Attachments:

createp.zip

Old KB# 4165