win32com and com Record types
Mark Hammond
mhammond at skippinet.com.au
Tue Aug 19 18:08:12 EDT 2003
Mike Margerum wrote:
> Hi I am trying to using a COM server I built in C++. I ran GenPy on
> my type library and I am able to instantiate objects from the server.
> What I can't figure out is how to create/use Record types from my COM
> server. I see them defined in my generated py file as a map
>
> RecordMap = {
> 'FormRecord': '{F6EBBC2A-E2D5-4921-A498-EA80AE851012}',
> 'ICD9Record': '{FA83723F-55F6-4D17-8309-A9D323A4FD01}',
> 'BrandRecord': '{AD4B5647-E78A-447B-A041-EEC59E89D3F6}',
> }
>
> How Do i instantiate one so I can use it in one of my methods that
> takes a BrandRecord by reference?
>
> This is a snippet of VB code that works
>
> Dim db As New BrandDb
> db.Open ("c:\temp\irx2_brand.pdb")
> Dim brandRec As BrandRecord
> While i < db.RecordCount
> db.GetBrand i, brandRec, 1 'use 0 instead of 1 to not load
> form data
> List1.AddItem brandRec.MasterIndex & " " & brandRec.Id & " " &
> brandRec.Description
You can create a record object by using:
r = win32com.client.Record("RecordName", object)
where "RecordName" is the name of the record, and 'object' is &any* COM
object defined in the same type library.
See win32com\test\testvb for some real examples.
Mark.
More information about the Python-list
mailing list