GenerateTypeLib function

Description

Creates a file with type library information for a PowerBuilder object you are deploying as an automation server.

Access

PowerBuilder.Application (automation server)

Syntax

{ automationobject.} GenerateTypeLib ( classguid, classname, progid, 
   localeid, majorversion, minorversion, description, helpcontext,
   helpfile, typelibguid, typelibfilename, registryfilename )

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.

classguid

A String whose value is the globally unique identifier (GUID) that you used for the object when you generated its registry file

classname

A String whose value is the name of the object in the PowerBuilder library for which type information will be generated.

classname should be the same name you specified when you generated the registry file.

progid

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

progid should be the same value you specified when you generated the registry file.

localeid

A Long whose value is the locale identifier (LCID) for the language of your object. Values for specific languages are defined in Microsoft documentation.

You can also specify a value of the PowerBuilder enumerated datatype LanguageID.

majorversion

An Integer whose value you specified for the major version number of your server object.

minorversion

An Integer whose value you specified for the minor version number of your server object.

description

A String whose value you specified as the description of your server object.

helpcontext

A Long whose value is the context ID for a Help topic in helpfile. Specify 0 to display the Help file’s contents page.

helpfile

A String whose value is the name of a Help file containing Help topics for your server object.

typelibguid

A String whose value will be the globally unique identifier (GUID) for the TypeLib information in the registry.

typelibfilename

A String whose value is the name of the file GenerateTypeLib will create. The default file name extension recognized by the registry is TLB.

registryfilename

A String whose value is the name of the registry update file generated for this object with GenerateRegFile.

If you just want to generate a type library, specify an empty string for registryfilename.

Returns

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

Usage

The type library is optional. You need it only if you want OLE browsers to display information about the properties and methods of your object.

If you want to register your type library, then a valid registry update file must exist for the object before you create the Type Library file. The process of creating the Type Library adds information to the registry update file.

To generate the registry update file, see the GenerateRegFile function.

The values you specify for the arguments of GenerateTypeLib must match the values in the associated registry update file that has already been created. Otherwise, you will create a TypeLib entry in the registry that is not associated with any object.

Before you call GenerateTypeLib, you must start a PowerBuilder.Application session and set the LibraryList and MachineCode properties to the values for the server object. You also need two GUIDs, the GUID used for the object’s CLSID (specified when you created the registry update file) and a GUID for the type library itself. For information about the format of a GUID, see the GenerateGUID function.

After you generate the registry update and type library files, you can register the object in the registry on your system or on other systems.

When you register your object in the registry, it stores information about the locations of the library file and the type library file. The path you specified for the LibraryList property specifies its location or must be in the path. The type library file should be in its intended directory when you register the object.

Examples

Example 1

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

long ll_result
ll_result = GenerateTypeLib( &
   "{12345678-1234-1234-1234-123456789012}", &
   "uo_salary_formulas", "MyCompany.SalaryFormulas", &
   0, 1, 0, &   
   "PowerBuilder functions for calculating salaries", &
   0, "c:\pbds\bizrules.hlp", &   
   "{12345679-1234-1234-1234-123456789012}", &
   "c:\pbds\bizrules.tlb",   "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, ls_typelibGUID
long ll_result

PBObject = CREATE oleObject

result = PBObject.ConnectToNewObject &
   ("PowerBuilder.Application")
IF result < 0 THEN
   // Handle the error
   RETURN -1
END IF

PBObject.LibraryList = "c:\myappl\mylibrary.pbd"
PBObject.MachineCode = FALSE

// GUID for object's CLSID
ll_result = PBObject.GenerateGUID(REF ls_GUID)
IF ll_result < 0 THEN
   // Handle the error
   RETURN -1
END IF

// GUID for object's Type Library
ll_result = PBObject.GenerateGUID(REF ls_typelibGUID)
IF ll_result < 0 THEN
   // Handle the error
   RETURN -1
END IF

// Generate registry update file
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
   RETURN -1
END IF

// Generate Type Library
ll_result = PBObject.GenerateTypeLib( ls_GUID, &   
   uo_myserverobject",   "MyCompany.Object",      0, 1, 0, &   
   "My object's description",   0, $
   "c:\myappl\myhelp.hlp", ls_typelibGUID, &
   "c:\myappl\object.tlb",   "c:\myappl\object.reg")
IF ll_result < 0 THEN
   // Handle the error
   RETURN -1
END IF

See also