Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Howto access a enumeration in a COM TypeLib (http://www.velocityreviews.com/forums/t346285-howto-access-a-enumeration-in-a-com-typelib.html)

Alexander Eisenhuth 06-21-2005 10:27 AM

Howto access a enumeration in a COM TypeLib
 
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.

Konstantin Veretennicov 06-21-2005 11:34 AM

Re: Howto access a enumeration in a COM TypeLib
 
On 6/21/05, Alexander Eisenhuth <newsuser@stacom-software.de> 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

Alexander Eisenhuth 06-21-2005 01:15 PM

Re: Howto access a enumeration in a COM TypeLib
 
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



All times are GMT. The time now is 09:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.