GenerateRegFile function

Description

Creates a file with registry update instructions for deploying a PowerBuilder object as an automation server.

Applies to

PowerBuilder.Application (automation server)

Syntax

{ automationobject.} GenerateRegFile ( guid, classname, progid, 
   majorversion, minorversion, description, outputfilename )

Argument

Description

automationobject

When PowerBuilder is the OLE client, the name of the OLEObject instantiated with the PowerBuilder.Application automation server. For other clients, use syntax appropriate for calling a function belonging to an automation object.

guid

A string whose value is the globally unique identifier (GUID) you want to use for the object

You can specify a GUID that you:

  • Generated with a call to GenerateGUID

  • Generated earlier and are reusing (because this object replaces an earlier version)

  • Received from Microsoft

classname

A string whose value is the name of the class user object that will be the automation server. The object must be in one of the libraries specified in the LibraryList property.

progid

A string whose value is the programmatic identifier that people will use to connect to your server.

majorversion

An integer whose value you want to use for the major version number of your server object.

minorversion

An integer whose value you want to use for the minor version number of your server object.

description

A string whose value is a description of your server object. The description will be displayed in the Registry Editor and other OLE browsers.

outputfilename

A string whose value is the name of the file the GenerateRegFile will create. The default file name extension recognized by the registry is REG.

Returns

Long. Returns a status code indicating whether an error occurred. Values are:

Usage

Before you call GenerateRegFile, you must start a PowerBuilder.Application session and set the LibraryList and MachineCode properties to the value that the server object will use. You also need a GUID to serve as the object’s class identifier (CLSID). For information about the format of a GUID, see the GenerateGUID function.

After you create a registry update file, you can also generate a type library file for the object, which provides browsing information for your server object. See the GenerateTypeLib function.

The default extension for a registry update file is REG. You can install the object in the registry by double-clicking on the update file. Information is installed in the registry about the object, including the location of its DLL and the location of its type library file, if any. For how to use a PowerBuilder tool to register objects, see “Registering the object”.

Examples

Example 1

This example calls GenerateRegFile. (Do not use this GUID in your own applications.)

long ll_result
ll_result = GenerateRegFile( &
   "{12345678-1234-1234-1234-123456789012}", &
   "uo_salary_formulas",   "MyCompany.SalaryFormulas", &
   1, 0, &
   "PowerBuilder functions for calculating salaries", &
   "c:\pbds\bizrules.reg")

This example establishes a PowerBuilder.Application server session and sets all the values necessary for generating a registry update file.

oleObject PBObject
string ls_GUID
long ll_result

PBObj = CREATE oleObject

result = &
  PBObj.ConnectToNewObject("PowerBuilder.Application")
IF result < 0 THEN
   // Handle the error
ELSE
   PBObject.LibraryList = "c:\myappl\mylibrary.pbd"
   PBObject.MachineCode = FALSE

   ll_result = PBObject.GenerateGUID(REF ls_GUID)
   IF ll_result < 0 THEN

   // Handle the error
   ELSE
   ll_result = PBObject.GenerateRegFile(   ls_GUID, &
      "uo_myserverobject",   "MyCompany.Object", &      
      1, 0,    "My object's description", &   
      "c:\myappl\object.reg")

   IF ll_result < 0 THEN
      // Handle the error
   ELSE
      // Generate Type Library
   END IF
   END IF
END IF

See also