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
1 |
{ <i>automationobject</i>.} <b>GenerateTypeLib</b> ( <i>classguid</i>, <i>classname</i>, <i>progid</i>, <br /> <i>localeid</i>, <i>majorversion</i>, <i>minorversion</i>, <i>description</i>, <i>helpcontext</i>,<br /> <i>helpfile</i>, <i>typelibguid</i>, <i>typelibfilename</i>, <i>registryfilename</i> ) |
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 documentationYou can also specify a value of the PowerBuilder enumerated data type 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 filename 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 |
Return Values
Long. Returns a status code indicating whether an error occurred.
Values are:
- 0 The registry update file was generated successfully
- 2 No output filename was provided
- 3 Can’t create the type library
- 4 Invalid name or error setting name
- 5 Invalid locale identifier or error setting the locale identifier
- 6 Error converting the TypeLib GUID to a CLSID
- 7 Invalid GUID or error setting GUID
- 7 Error setting description
- 9 Error setting version
- 10 Error setting Help context
- 11 Error setting Help filename
- 14 Class not found in the libraries specified in LibraryList
- 18 Error converting ClassName GUID to CLSID
- 30 Error loading standard type library (OLE is not installed
correctly) - 31 Error getting IUnknown type information (OLE is not installed
correctly) - 32 Error getting IDispatch type information (OLE is not installed
correctly) - 36 Error opening the registry update file associated with this
type library
Usage
The type library is optional. You only need it 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, before you
create the Type Library file, a valid registry update file must
exist for the object. 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 be creating a TypeLib
entry in the registry that isn’t 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
This example calls GenerateTypeLib. (Don’t
use this GUID in your own applications!)
1 |
long ll_result |
1 |
ll_result = <i>GenerateTypeLib</i> ( & |
1 |
"{12345678-1234-1234-1234-123456789012}", & |
1 |
"uo_salary_formulas", & |
1 |
"MyCompany.SalaryFormulas", & |
1 |
0, 1, 0, & |
1 |
"PowerBuilder functions for calculating & |
1 |
salaries", & |
1 |
0, "c:pbdsizrules.hlp", & |
1 |
"{12345679-1234-1234-1234-123456789012}", & |
1 |
"c:pbdsizrules.tlb"" |
1 |
"c:pbdsizrules.reg") |
This example establishes a PowerBuilder.Application server session
and sets all the values necessary for generating a registry update
file:
1 |
oleObject PBObject |
1 |
string ls_GUID, ls_typelibGUID |
1 |
long ll_result |
1 |
1 |
PBObject = CREATE oleObject |
1 |
1 |
result = PBObject.ConnectToNewObject & |
1 |
("PowerBuilder.Application") |
1 |
IF result < 0 THEN |
1 |
// Handle the error |
1 |
RETURN -1 |
1 |
END IF |
1 |
1 |
PBObject.LibraryList = "c:myapplmylibrary.pbd" |
1 |
PBObject.MachineCode = FALSE |
1 |
1 |
// GUID for object's CLSID |
1 |
ll_result = PBObject.GenerateGUID(REF ls_GUID) |
1 |
IF ll_result < 0 THEN |
1 |
/ Handle the error |
1 |
RETURN -1 |
1 |
END IF |
1 |
1 |
// GUID for object's Type Library |
1 |
ll_result = PBObject.GenerateGUID(REF ls_typelibGUID) |
1 |
IF ll_result < 0 THEN |
1 |
// Handle the error |
1 |
RETURN -1 |
1 |
END IF |
1 |
1 |
// Generate registry update file |
1 |
ll_result = PBObject.GenerateRegFile( & |
1 |
ls_GUID, & |
1 |
"uo_myserverobject", & |
1 |
"MyCompany.Object", & |
1 |
1, 0, & |
1 |
"My object's description", & |
1 |
"c:myapplobject.reg") |
1 |
IF ll_result < 0 THEN |
1 |
/ Handle the error |
1 |
RETURN -1 |
1 |
END IF |
1 |
1 |
// Generate Type Library |
1 |
ll_result = PBObject.GenerateRegFile( & |
1 |
ls_GUID, & |
1 |
uo_myserverobject", & |
1 |
"MyCompany.Object", & |
1 |
0, 1, 0, & |
1 |
"My object's description", & |
1 |
0, "c:myapplmyhelp.hlp", & |
1 |
ls_typelibGUID, & |
1 |
"c:myapplobject.tlb", & |
1 |
"c:myapplobject.reg") |
1 |
IF ll_result < 0 THEN |
1 |
// Handle the error |
1 |
RETURN -1 |
1 |
END IF |
See Also
- GenerateGUID
- GenerateRegFile
Exception codes
Automation clients accessing a PowerBuilder server may generate
OLE exceptions under certain circumstances. When user actions cause
an exception, PowerBuilder populates the EXCEPINFO structure passed
by the caller with an exception code identifying the type of exception.
For a PowerBuilder client, the exception information is passed as
arguments to the ExternalException event.
Client applications may receive these exception codes from
the PowerBuilder automation server:
Code | Meaning |
---|---|
1001 | Memory allocation failure |
1002 | Requested Object is not in the library list |
1003 | Object create failed |
1004 | Binary format does not match version or is out of date |
1005 | Property accessed as an array is not an array |
1006 | Unexpected error executing script |
1007 | No method was found matching the requested name and argument types |
1008 | Unable to convert variant argument type |
Sample registry update file
This sample registry file has registration information for
a class user object named uo_salarydata.
Indented lines are continuations of the previous line. They
would appear as a single line in the actual file:
1 |
REGEDIT4 |
1 |
;;;;;;;;;;;;;;;; |
1 |
; |
1 |
; Registry entries for MyCompany.SalaryData |
1 |
; |
1 |
; CLSID = {E022EF01-6789-11CF-92BF-00805F9236E9} |
1 |
; |
1 |
; PowerBuilder Generated Registry File |
1 |
;;;;;;;;;;;;;;;; |
1 |
; Version independent entries: |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryData] |
1 |
@="DataStore with functions returning salary |
1 |
statistics" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryDataCLSID] |
1 |
@="{E022EF01-6789-11CF-92BF-00805F9236E9}" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryDataCurVer] |
1 |
@="MyCompany.SalaryData.1" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryDataNotInsertable" |
1 |
@="" |
1 |
1 |
; Version specific entries: |
1 |
[HKEY_CLASSES_ROOTAppID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}] |
1 |
@="DataStore with functions returning salary |
1 |
statistics" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryData.1] |
1 |
@="DataStore with functions returning salary |
1 |
statistics" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryData.1CLSID] |
1 |
@="{E022EF01-6789-11CF-92BF-00805F9236E9}" |
1 |
[HKEY_CLASSES_ROOTMyCompany.SalaryData.1 |
1 |
NotInsertable] |
1 |
@="" |
1 |
1 |
; CLSID entries: |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}] |
1 |
@="DataStore with functions returning salary |
1 |
statistics" |
1 |
"AppID"="{E022EF01-6789-11CF-92BF-00805F9236E9}" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
0805F9236E9}ProgID] |
1 |
@="MyCompany.SalaryData.1" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}VersionIndependentProgID] |
1 |
@="MyCompany.SalaryData" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}InProcServer32] |
1 |
@="pbVM70.dll" |
1 |
"ThreadingModel"="Apartment" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}NotInsertable] |
1 |
@="" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}Programmable] |
1 |
@="" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}PowerBuilderClassName] |
1 |
@="uo_salarydata" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}PowerBuilderLibraryList] |
1 |
@="D:\pbserver.pbd" |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}PowerBuilderBinaryType] |
1 |
@="PCODE" |
1 |
; Type Library Registration entries: |
1 |
[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF- |
1 |
00805F9236E9}TypeLib] |
1 |
@="{E022EF02-6789-11CF-92BF-00805F9236E9}" |
1 |
[HKEY_CLASSES_ROOTTypeLib{E022EF02-6789-11CF-92BF- |
1 |
00805F9236E9}1.0] |
1 |
@="Type Library for DataStore with functions |
1 |
returning salary statistics" |
1 |
[HKEY_CLASSES_ROOTTypeLib{E022EF02-6789-11CF-92BF- |
1 |
00805F9236E9}1.09Win32] |
1 |
@="D:\pbserver.tlb" |