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

  • SEARCH
  • Home
  • 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 8354521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:34:20+00:00 2026-06-09T09:34:20+00:00

I am trying to create a com client to send messages to a server.

  • 0

I am trying to create a com client to send messages to a server. I have the ole viewer definitions and created the structures(classes) in python, that are used to construct a complex structure that has more structures and enums in it.

Everything seems to be going well, but when i try to pass a SampleObject* to the client call, i get this error :

ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>:
expected LP__SampleObject instance instead of LP__SampleObject

Which seems pretty weird. What i am doing is something like(this is where i get the error) :

dialog = _SampleObject('hello', struct1, 'hi_there', struct2, 1, struct3, 1, 1, 1, 'me', 'you', 'him')
obj.COM_function( pointer(dialog) )

I’ve tried many things, but cannot get around that error. Any ideas ?

(obj is just a cc.CreateObject() coclass object, which works with no problems)

I really can’t see the problem, even the comtype definition displays that in the interface :

( ['in'], POINTER(_SampleObject), 'pAction' ),

which fits perfectly with pointer(dialog). This is a very weird error, could it be a but on comtypes ?

  • 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-09T09:34:21+00:00Added an answer on June 9, 2026 at 9:34 am

    Are you defining the ctypes structs and unions of your arguments more than once?

    If you define a Structure or Union subclass, use it in the argtypes of a C library function, redefine the structure or union and then attempt to pass an instance of the redefined class to the C function, you will get an error similar to the one you’re seeing.

    I took the code I used in this answer and added a (completely unnecessary) redefinition of the structure used with it. (I also changed the byref at the end to pointer – using byref gives you a different error message.) The Python code ended up as follows:

    from ctypes import *
    
    class TestStruct(Structure):
        _fields_ = [("a", c_int),
                    ("array", (c_float * 4) * 30)]
    
    slib = CDLL("slib.dll")
    slib.print_struct.argtypes = [POINTER(TestStruct)]
    slib.print_struct.restype = None
    
    # Redefine the ctypes structure.
    class TestStruct(Structure):
        _fields_ = [("a", c_int),
                    ("array", (c_float * 4) * 30)]
    
    t = TestStruct()
    
    for i in range(30):
        for j in range(4):
            t.array[i][j] = i + 0.1*j
    
    slib.print_struct(pointer(t))
    

    When I ran this modified script, I got the following output:

    C:\Users\Luke\Python stuff>slib2.py
    Traceback (most recent call last):
      File "C:\Users\Luke\Python stuff\slib2.py", line 21, in <module>
        slib.print_struct(pointer(t))
    ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: expected LP_TestStruct instance instead of LP_TestStruct
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create COM -object on server. code is: var myGuid = new Guid(530A1815-820C-11D3-BBB7-008048DE406A);
I'm trying to send an xml message to a server from a client app
I'm trying to create a DHCP Client using Java. The client will send Discover,
I'm trying to create some XML files on the client and then send them
I'm trying to receive JMS messages from a GlassFish (2.1) server remotely. I have
I am trying to create some charts of data (eg http://www.amibroker.com/ ). Is there
I'm trying to create tiny urls like this: site.com/abc123 goes to: site.com/index.php?token=abc123 but I
I'm trying to create this effect: http://www.thecssninja.com/demo/css_tree/ the problem I'm having is that the
I am trying to create a chat application on heroku using the following https://github.com/tarnfeld/PusherChat-Rails
I'm trying to create component: <?xml version=1.0?> <s:VGroup xmlns:mx=http://www.adobe.com/2006/mxml xmlns:s=library://ns.adobe.com/flex/spark> <mx:DataGrid id=letDataGrid width=100% height=100%

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.