Adopt COM-Server Wrapper from Python to Julia

Under python the script „“ exists, it generates a wrapper for a specified COM-server.
I wonder, can this wrapper code be rewritten in Julia-Style?
If there is someone who offers such a service on the basis of a “contract for specific work” I would be interested in a quote.

I was mostly curious to know more about this project, so I googled, and I suppose it could be done (but I will not), since I think everything you can to in Python (at least on Windows) can be done in Julia. I see most of the project is in C++ (but I don’t think that changes things), assuming it that first one:

I do see the file itself is rather small (at 455 lines): pywin32/ at main · mhammond/pywin32 · GitHub

it’s a generator, so possibly it’s easiest to change that file (and keep it in Python would then be ok) to rather generate Julia code. Since the generated code, is now, in Python, there might be lots more you need to translate, or not, just use PyCall.jl, or maybe rather by now PythonCall.jl? I.e. generate Julia code that uses Python libraries, and thus Python also, was that what you wanted?

There are two main types of servers, in-process and out-of-process. In-process servers are implemented in a dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process servers can reside either on the local computer or on a remote computer.

Before I comment on that, I think you’re not asking to make a Julia COM server (that answer would be a bit involved), just a client for it, which the code should generate for you.

I haven’t seen much Windows-specific Julia code. Julia itself is cross-platform, most to not call the Win32 API directly (I’ve however seen a project for doing that, of course then tying you to Windows, or Wine e.g. under Linux), such as for a Windows GUI. [I’ve not seen anything for COM yet in Julia. EDIT: found your post below:

Personally I would like most to use cross-platform libraries such as Qt or GTK, also supporting Windows, or whatever is a COM replacement, if there is anything such (is there, or only a Linux replacement, but no abstraction targeting that or Windows?). If you need/want COM, I guess you do, but I’m curious, can you tell me what for?

It might be nice to know the real (business) problem you want solved. Maybe there’s another way, and this is an XY problem.

Before finding what I believe is the right code (please confirm), I also found:

there the code is only 390 lines (if someone want to start translating, I guess a slightly older version): Pywin32/ at master · SublimeText/Pywin32 · GitHub

Hi Palli,

it is an “In-process server” provided by a the manufacturer of a digitizer /
oscilloscope. The COM-interface as well as the software of the HW is MS-windows only.
In matlab it is quite convenient to invoke / create this COM In-process server.
The command to create the object and to use the server to open access to the proprietary binary file is:

myObject = actxserver('ServerName');
myObject.invoke('Open', 'data_file_name');

Unfortunately, under Octave the same approach fails.

Maybe the python win32com works, but I have not yet figured out, what the trick is.
Up to now I have only worked with PyCall.jl I will have a look on PythonCall.jl, maybe this better suited to achieve my purpose.
The objective is to transfer a proprietary binary file format into a mat-file.
Unfortunately, my C-Coding skills are quite limited.
Meanwhile, I received an interesting link that deals with my topic:
Accessing COM from Julia
If someone is interested to receive the wrapper created by means of the python script by mhammond please send my a note.

1 Like


this morning I tried again to get it into operation in Python and today managed
to do it in the right manner:

import win32com.client
from os.path import exists as file_exists

IFileManager_Object = win32com.client.Dispatch("COM_ServerName")

FN_iFile = 'C:/data/data_log/Data_Types/iFile/iFile'

if (not file_exists(FN_iFile)):
    raise TypeError("File not found!")

n_channels = COM_ServerObject.GetChannelCount('')

If the documentation of your COM-Server is not complete, the python script by “mhammond” helps to figure out which function are available.

The same code under Julia looks like this:

# Create COM server via Python Interface
# first: install "pywin32" via conda:
# using Conda; Conda.add("pywin32")

using PyCall
pwc = pyimport("win32com.client")

COM_ServerObject = pwc.Dispatch("COM_ServerName")

FN_iFile = raw"C:\data\data_log\Data_Types\iFile\ifile_name";
if ~isfile(FN_iFile)
    error("file \"" * FN_mat * "\" does not exist!\n")

n_channels = COM_ServerObject.GetChannelCount("")

1 Like