GenerateTypeLib function
Description
Creates a file with type library information for a PowerBuilder
object you are deploying as an automation server.
Controls
PowerBuilder.Application (automation server)
Syntax
|
1 |
{ <i>automationobject</i>.} GenerateTypeLib ( <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 |
| 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 |
| 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 |
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 file name was provided.
- 3 Cannot 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 file name.
- 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 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
This example calls GenerateTypeLib.
(Do not 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", "MyCompany.SalaryFormulas", & |
|
1 |
0, 1, 0, & |
|
1 |
"PowerBuilder functions for calculating salaries", & |
|
1 |
0, "c:pbdsizrules.hlp", & |
|
1 |
"{12345679-1234-1234-1234-123456789012}", & |
|
1 |
"c:pbdsizrules.tlb", "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( ls_GUID, & |
|
1 |
"uo_myserverobject", "MyCompany.Object", & |
|
1 |
1, 0, "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.<i>GenerateTypeLib</i>( ls_GUID, & |
|
1 |
uo_myserverobject", "MyCompany.Object", 0, 1, 0, & |
|
1 |
"My object's description", 0, $ |
|
1 |
"c:myapplmyhelp.hlp", ls_typelibGUID, & |
|
1 |
"c:myapplobject.tlb", "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 might 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.
|
1 |
REGEDIT4<br />;;;;;;;;;;;;;;;;<br />;<br />; Registry entries for MyCompany.SalaryData<br />;<br />; CLSID = {E022EF01-6789-11CF-92BF-00805F9236E9}<br />;<br />; PowerBuilder Generated Registry File<br />;;;;;;;;;;;;;;;;<br />; Version independent entries:<br />[HKEY_CLASSES_ROOTMyCompany.SalaryData]<br />@="DataStore with functions returning salary statistics"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryDataCLSID]<br />@="{E022EF01-6789-11CF-92BF-00805F9236E9}"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryDataCurVer]<br />@="MyCompany.SalaryData.1"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryDataNotInsertable"<br />@=""<br /> <br />; Version specific entries:<br />[HKEY_CLASSES_ROOTAppID{E022EF01-6789-11CF-92BF-00805F9236E9}]<br />@="DataStore with functions returning salary statistics"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryData.1]<br />@="DataStore with functions returning salary statistics"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryData.1CLSID]<br />@="{E022EF01-6789-11CF-92BF-00805F9236E9}"<br />[HKEY_CLASSES_ROOTMyCompany.SalaryData.1NotInsertable]<br />@=""<br /> <br />; CLSID entries:<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-<br />00805F9236E9}]<br />@="DataStore with functions returning salary statistics"<br />"AppID"="{E022EF01-6789-11CF-92BF-00805F9236E9}"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-0805F9236E9}ProgID]<br />@="MyCompany.SalaryData.1"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}VersionIndependentProgID]<br />@="MyCompany.SalaryData"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}InProcServer32]<br />@="pbVM105.dll"<br />"ThreadingModel"="Apartment"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF 00805F9236E9}NotInsertable]<br />@=""<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}Programmable]<br />@=""<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}PowerBuilderClassName]<br />@="uo_salarydata"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}PowerBuilderLibraryList]<br />@="D:\pbserver.pbd"<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}PowerBuilderBinaryType]<br />@="PCODE"<br />; Type Library Registration entries:<br />[HKEY_CLASSES_ROOTCLSID{E022EF01-6789-11CF-92BF-00805F9236E9}TypeLib]<br />@="{E022EF02-6789-11CF-92BF-00805F9236E9}"<br />[HKEY_CLASSES_ROOTTypeLib{E022EF02-6789-11CF-92BF-00805F9236E9}1.0]<br />@="Type Library for DataStore with functions returning salary statistics"<br />[HKEY_CLASSES_ROOTTypeLib{E022EF02-6789-11CF-92BF- 00805F9236E9}1.09Win32]<br />@="D:\pbserver.tlb" |