Howto access a enumeration in a COM TypeLib

Discussion in 'Python' started by Alexander Eisenhuth, Jun 21, 2005.

  1. Hello alltogether,

    I hope somebody can help me in that case. I bet I have overseen s.th..

    I have a VC++ IDispatch Com-Server (ATL) and include for error handling
    issues a enumeration in the IDL-File.

    [...]
    enum PROG_ERROR {
    P_OK = 0,
    P_ERR_01 = 1,
    P_ERR_02 = 2,
    ...
    }
    typedef enum PROG_ERROR PROG_ERROR_T;

    [...]

    I can acess the COM object using :

    obj = win32com.client.Dispatch("...")

    and can Load the TypeLib:

    lib = pythonwin.LoadTypeLib("...")

    and see the enumeration in the OLE-Browser of Windows, but don't know
    how to access the enum in Python.

    Any help and hints are very welcome.

    Regards
    Alexander

    PS.: I use the actual version of ActivePython 2.4.
     
    Alexander Eisenhuth, Jun 21, 2005
    #1
    1. Advertising

  2. On 6/21/05, Alexander Eisenhuth <> wrote:
    > Hello alltogether,
    >
    > I hope somebody can help me in that case. I bet I have overseen s.th..
    >
    > I have a VC++ IDispatch Com-Server (ATL) and include for error handling
    > issues a enumeration in the IDL-File.
    >
    > [...]
    > enum PROG_ERROR {
    > P_OK = 0,
    > P_ERR_01 = 1,
    > P_ERR_02 = 2,
    > ...
    > }
    > typedef enum PROG_ERROR PROG_ERROR_T;
    >
    > [...]
    >
    > I can acess the COM object using :
    >
    > obj = win32com.client.Dispatch("...")
    >
    > and can Load the TypeLib:
    >
    > lib = pythonwin.LoadTypeLib("...")
    >
    > and see the enumeration in the OLE-Browser of Windows, but don't know
    > how to access the enum in Python.
    >
    > Any help and hints are very welcome.
    >
    > Regards
    > Alexander
    >
    > PS.: I use the actual version of ActivePython 2.4.


    Use site-packages/win32com/client/makepy.py to produce myserver.py
    from your typelib file, then
    >>> import myserver
    >>> print myserver.constants. P_OK

    0

    Maybe you can access constants without makepy, I don't know.

    - kv
     
    Konstantin Veretennicov, Jun 21, 2005
    #2
    1. Advertising

  3. Thanks, thats it.

    Konstantin Veretennicov schrieb:

    >>>>import myserver
    >>>>print myserver.constants. P_OK

    > 0
    >
    > Maybe you can access constants without makepy, I don't know.
    >
    > - kv
     
    Alexander Eisenhuth, Jun 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    291
  2. Paul McGuire

    win32com typelib difficulty

    Paul McGuire, May 24, 2004, in forum: Python
    Replies:
    0
    Views:
    521
    Paul McGuire
    May 24, 2004
  3. puvit82
    Replies:
    4
    Views:
    768
    puvit82
    Feb 1, 2008
  4. Vince C.
    Replies:
    12
    Views:
    269
    Vince C.
    Jan 15, 2004
  5. Thomas Born
    Replies:
    1
    Views:
    164
    Thomas Born
    Feb 9, 2004
Loading...

Share This Page