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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:47:33+00:00 2026-06-07T06:47:33+00:00

I am writing a python script to control a Com object. The official documentation

  • 0

I am writing a python script to control a Com object. The official documentation is in C#, VB and C.
the documentation (in VB) is as follows:

Public Function GetDATA { 
ByVal vecRecords() As DATAType,
ByRef Time As String, 
optional ByVal filter1 As String, 
optional ByVal kind2 As Kind = KindAll, 
optional ByVal type1 As Types = TypeAll 
) As Long 

As far as i can tell, the 1st argument is the return value and is returned as normal in python. Last three arguments are enum types (translated in to numbers) but are optional in any case.
I am left wit the question what argument do I pass in “ByRef Time As String”?

my code is:

>>> from win32com.client import Dispatch
>>> Obj = Dispatch("Service.Foo")
>>> Obj.Function()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python27\lib\site-packages\win32com\gen_py\48C77DB1-D9E0-45B8-9992-C9
2B047CC700x0x1x0.py", line 399, in Function 
    , LastTime, BNO, kind, madadType)
  File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 456, in
 _ApplyTypes_
    self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147023170, 'The remote procedure call failed.', None, None)

I also ran:

>>> Obj.Function()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python27\lib\site-packages\win32com\gen_py\48C77DB1-D9E0-45B8-9992-C9
2B047CC700x0x1x0.py", line 399, in Function 
    , LastTime, BNO, kind, madadType)
  File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 456, in
 _ApplyTypes_
     self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
 TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a bufferobject.

and:

>>> a= ("00000000","00000000",-1,-1)
>>> Obj.Function(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python27\lib\site-packages\win32com\gen_py\48C77DB1-D9E0-45B8-9992-C9
2B047CC700x0x1x0.py", line 399, in Function 
    , LastTime, BNO, kind, madadType)
  File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 456, in
 _ApplyTypes_
     self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
MemoryError: CreatingSafeArray

The retvalue is not too big, so i really do not understand the last one.

system:
windows 7 64bit.
python 2.7.2 32 bit (running from cmd started as administrator, the COM object needs it.)

Is there a simple way to discover what the function wants?

Thanks in advance
Marbs.

[Edit]
I give you a working C# Code Snippet:

System.Array tempArray;
string lTime = "00000000";
Res = Obj.getDATA(out tempArray, ref lTime, "0", Obj.type1, Obj.type2);  

Where Obj.type1 and Obj.type2 are enums form the Obj it self. They both translate in to -1 (an int).

  • 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-07T06:47:35+00:00Added an answer on June 7, 2026 at 6:47 am

    When writing in VB, and using the ByRef switch like in the decryption ByRef Time As String, from my question, the function changes the actual variable (like a pointer in c++).

    This COM object tried changing some memory it was not allowed to change. That is why I got a memory error when running it in python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing python script which gets links from website. But when I tried
I am writing python scripts and execute them in a Makefile. The python script
I'm writing a Python script, and it needs to print a line to console.
I'm writing a python script to extract data out of our 2GB Apache access
I'm writing a Python script at work that contains a part with a large
Im in the process of writing a python script to act as a glue
I'm writing a Python backup script and I need to find the oldest file
I amm writing a little python script that will grab information from VMs of
I am writing a simple Python script with no GUI. I want to be
I am writing a python command line script that takes a .ldif and two

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.