Skip to main content

Problem:

This illustrates accessing the Windows registry with COBOL and writing or reading information from the registry

Resolution:

INTRODUCTION

==========

This example demonstrates the use of the Win32 API function calls to access and create system Registry entries from within a COBOL program. In this example, we will create a new Registry key called "TestKey" which is a subkey of the Windows standard HK_CURRENT_USERS key. It will then create a null terminated string value name for this key and populate it with a value. It will then close the Registry, reopen the key, read the keys value and display the value to the user.

You can check this keys existance after running this program by using the Windows program REGEDIT to view the Registry.

SOURCE FILES:

==========

Program Files      Description

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

COBREG.CBL       Program that calls the Registry functions.

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

                           constants.

REQUIREMENTS:

==========

This sample should run in all environments as long as you have sufficient user rights to create and modify the System Registry. To link this program or any program that uses these functions as an .EXE, the import library ADVAPI32.LIB must be specified in the Project Build Settings/Link/Advanced library options. This import library is supplied in the Net Express\\Base\\Lib directory.

OPERATION:

========

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

NOTE:

====

To link this program or any program that uses these functions as an .EXE, the import library ADVAPI32.LIB must be specified in the Project Build Settings/Link/Advanced library options. This import library is supplied in the Net Express\\Base\\Lib directory.

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

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

demo.ex

demo.me

demo.ne

Attachments:

cobreg.zip

Old KB# 4163