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 8235183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:43:11+00:00 2026-06-07T18:43:11+00:00

I have to create a tlb file so I can access a Python COM

  • 0

I have to create a tlb file so I can access a Python COM server from .Net. I only want a single method (Process) that takes a string and returns a string. The idl file is below:

import "oaidl.idl";
import "ocidl.idl";
[
    uuid(A66551C8-ADB4-4A1E-BB19-39F356282A7E),
    dual,
    oleautomation
]
interface IMyInterface : IDispatch {
    HRESULT Process([in, out] BSTR str);
}

[
  uuid(BE0CDA23-A2D0-40E5-8D33-61DBE78E0A03)
]
library MyTypeLib
{
    importlib("stdole2.tlb");

    [uuid(F235B9D8-9C1A-44C3-A59F-3C822EC82A67)]
          coclass MyObject {
          [default] interface IMyInterface;
    };
};

Using midl this successfully generates a tlb file
The python program is below:

import comtypes
import comtypes.server.localserver

from comtypes.client import GetModule
# generate wrapper code for the type library, this needs
# to be done only once (but also each time the IDL file changes)
GetModule("audiclave.tlb")

from comtypes.gen.MyTypeLib import MyObject

class AudiclaveImpl(MyObject):
    # registry entries
    _reg_threading_ = "Both"
    _reg_progid_ = "Audiclave.Analysis.1"
    _reg_novers_progid_ = "Audiclave.Analysis"
    _reg_desc_ = "Python engine for Audiclave"
    _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER
    _regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE

    def Process(self, a):
        return str(a) + "executed"


if __name__ == "__main__":
    from comtypes.server.register import UseCommandLine
    UseCommandLine(AudiclaveImpl)

I run that with

python audiclaveAnalysis.py /regserver

Now I open python and do the following:

>>> from comtypes.client import CreateObject
>>> x = CreateObject("Audiclave.Analysis")
# Generating comtypes.gen._BE0CDA23_A2D0_40E5_8D33_61DBE78E0A03_0_0_0
>>> x.Process("test")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\comtypes\__init__.py", line 596, in call_with_inout
v = atyp.from_param(v)
AttributeError: 'str' object has no attribute 'from_param'

How do I define a method to take a string parameter and return one?

  • 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-07T18:43:13+00:00Added an answer on June 7, 2026 at 6:43 pm

    This worked

    HRESULT Process([in] BSTR str, [out, retval] VARIANT *pResult);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .Net COM server that has a method that takes a message
The problem is, I have a DLL and TLB that I created in C#.NET,
I have create a bunch of .o files (via gcc -c $file.c $someotherops -o
I have create a vcf file that contains contacts by using this code ContentResolver
I have create my own NSOpenGLView class, right now the data that i want
I have a C# ComServerProject that implements an out-of-proc COM server, and I've selected
I create a C# COM interop for c++ to invoke. I have registered the
I have a .net component that will be called by unmanaged code. I want
I have a header-file, the COM interface. I have created a small win32 program
I have a .NET dll which has some interfaces\classes which are exposed to com.

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.