[python-win32] Python COM User Defined Types

Jens B. Jorgensen jens.jorgensen@tallan.com
Fri, 21 Feb 2003 09:38:42 -0600


I don't know if this is true or not but I'm going to guess that UDTs are 
supported /if/ they have an IRecordInfo for them. This is a COM 
interface that can actually handle all manipulation of the UDT. VB 
generates these for its UDTs and this is how Automation-compatible 
languages support them. I'm guessing Mark will comment on this.

william.rooney@us.transport.bombardier.com wrote:

>I am using ActivePython 2.2 Build 224 on Microsoft Windows 2000 SP2.
>
>I have a COM server that has some User Defined Types in the .idl file.  These
>UDTs are parameters in some of the methods.
>I have run makepy against the type library of the COM server, with the -i option
> and included the two lines in my Python code.
>All of the documentation that I have found regarding "records" and "structs" in
>COM servers has indicated that I should be able to
>to use this COM server with early binding and also be able use these UDTs.  My
>problem is that I can not seem to actually do it.
>I wonder if I misunderstood the documents that I found.  Also the
>mk:@MSITStore:C:\Python22\Doc\win32com.chm::/messages.html
>in the help file (and Classes and class members, Functions, and Structures and
>Enumberations) is empty.
>
>How can I create variables in my Python code and use them when calling the
>WriteMsg2 method (below)?  Why do I not get a list of
>available constants when I type "win32com.clients.constants."  Typically after
>entering the period at the end of an object I am presented
>with a list of attributes/constants/methods.
>
>
>I am concerned by these lines from the file generated by makepy:
># The following 3 lines may need tweaking for the particular server
># Candidates are pythoncom.Missing and pythoncom.Empty
>defaultNamedOptArg=pythoncom.Missing
>defaultNamedNotOptArg=pythoncom.Missing
>defaultUnnamedArg=pythoncom.Missing
>
>I do not know what to do about the pythoncom.Missing and pythoncom.Empty
>candidates.  What should be done about them?
>
>Can I simply create an object of type StackObj like this:
>myStack = StackObj()
>Reference these two lines from the makepy generated file:
># This CoClass is known by the name 'Stack.StackObj.1'
>class StackObj(CoClassBaseClass): # A CoClass
>
>
>snippet from Python code:
>stack = win32com.client.Dispatch("Stack.StackObj")
>
>snippet from the .idl:
>  cpp_quote("#pragma pack(push) // save the default packing alignment, typically
> 8")
>  cpp_quote("#pragma pack(1) // we rely on sizeof() for the sizes of these
>structures, tell the compiler not to pad")
>  [
>    uuid(1FFA712A-14FB-4451-BE52-7B88BBE34DCE),
>    helpstring("Revision Info: software and config version and protocol
>version")
>  ]
>  typedef struct tagREVISION_LEVELS2
>  {
>    short software_rev;
>    long  config_rev;
>    BYTE  icd_rev;
>  } REVISION_LEVELS2;
>  cpp_quote("#pragma pack(pop) // restore the default packing alignment")
>
>  interface IStackObj : IDispatch
>  {
>    ...
>    [id(7), helpstring("method WriteMsg2")] HRESULT WriteMsg2([in] struct
>tagVB_REVISION_LEVELS2* pRevisionInfo, [in] struct tagVB_HEADER_INFO2* pHeader,
>[in,out] SAFEARRAY(BYTE)* psaMsg);
>  }
>
>Thanks for all your help,
>----Bill Rooney
>
>
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32@python.org
>http://mail.python.org/mailman/listinfo/python-win32
>  
>

-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"