Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:46:30+00:00 2026-06-11T08:46:30+00:00

I have to get event from COM API which has description: HRESULT OnStatusMessage( [in]

  • 0

I have to get event from COM API which has description:

HRESULT OnStatusMessage(
    [in] IDispatch* pStatusMessage
);

And IStatusMessage has properties: BSTR Description, LONG Code, etc.

My code doesn’t work:

import msvcrt
import pythoncom
from win32com.client import DispatchWithEvents

class evt(object):
    def OnConnectionLost(self):
        print 'method ConnectionLost'
    def OnStatusMessage(self, s):
        print 'method OnStatusMessage: '  + str(s.Description)
    def OnLogin(self, l):
        print 'method OnLogin:', l
    def OnMessage(self, msg):
    print 'method OnMessage'


session = DispatchWithEvents("NiApi.SrvrSession", evt)
# login settings....

session.Connect()

while 1:
    if msvcrt.kbhit():
    msvcrt.getch()
        session.Disconnect()
        break
    pythoncom.PumpWaitingMessages()

Module fails with traceback:

Traceback (most recent call last):
  File "C:\Python\AP_272\lib\site-packages\win32com\server\policy.py", line 277, in     _Invoke_
    return self._invoke_(dispid, lcid, wFlags, args)
  File "C:\Python\AP_272\lib\site-packages\win32com\server\policy.py", line 282, in _invoke_
    return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
  File "C:\Python\AP_272\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_
    return func(*args)
  File "d:\niapi.py", line 13, in OnStatusMessage
    print 'method OnStatusMessage' + str(s.Description)
AttributeError: 'PyIDispatch' object has no attribute 'Description'
pythoncom error: Python error invoking COM method.

Why i cant get this attribute?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:46:31+00:00Added an answer on June 11, 2026 at 8:46 am

    I’ve found the answer here:

    Need to dispatch this object:

    message = Dispatch(s)
    print 'method OnStatusMessage', str(message.Description)
    

    And don’t forget to import Dispatch

    from win32com.client import Dispatch
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop a program where I need to get the event from
I have a QTableView that I need to get the selectionChanged event from. I
I'm making an iPhone app in which I retrieve JSON data from http://maps.googleapis.com/maps/api/geocode/json?address=canada&sensor=true ,
I have a subclass of NSView where I'm handling the -mouseDown: event to get
I have a text box with event name and two calendar controls to get
I have an exsiting event which I'm trying to invite users to using this
I have this code from the Google API docs. It does exactly what I
I have a project (named Product.Api ) that has some controllers used for our
I have a class that contains this class method: def self.get_event_record(row, participant) event =
Bit confused here, I have an on-demand instance but do I get charged even

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.