[python-win32] How to create a com_record?

Mark Hammond mhammond at skippinet.com.au
Fri Feb 1 06:34:42 CET 2008


The record will be defined in a typelib somewhere, and have named elements.
For example, the win32com test VB code:

 

Public Type VBStruct

    int_val As Integer

    str_val As String

    ob_val As Object

    sub_val As SubStruct

End Type

 

And VB arranges for that to become a COM record.  Python code can then say:

 

    s = win32com.client.Record("VBStruct", vbtest)

    s.int_val = -1

 

(Where vbtest in the first line is a COM object that comes from the same
typelib which defines the struct).  The object 's' can then be passed as a
param, where it will become VT_RECORD.  Without knowing how the struct is
defined in your case I can't speculate how a GUID would be carried.  If it
was a simply array of bytes, then using 'buffer(guid)' will give you the raw
bytes.

 

Cheers,

 

Mark

 

From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Kevin Patterson
Sent: Friday, 1 February 2008 2:34 PM
To: python-win32 at python.org
Subject: [python-win32] How to create a com_record?

 

I have a COM server that is expecting a GUID as an argument. The generated
makepy shows that the function is expecting a VT_RECORD. I cannot seem to
pass in the CLSID, I get the following:

TypeError: Only com_record objects can be used as records

I looked at the win32com.client.Record function, but it looks like it will
create another COM object if I give it the GUID.What I really need is to
pass the GUID in to this function as a sort of structure.  I "think" I have
to build a struct (using the struct class?) turn it into a buffer and then
somehow convert this to a Record object....Trouble is I can't find any
documentation on com_record objects anywhere....Any ideas?

Thanks,
Kevin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080201/d5d8742e/attachment.htm 


More information about the python-win32 mailing list