1

I am running a python script to interface with a c# dll registered as a com application and having difficulty handling an output struct parameter. I create a COM record and successfully pass this into my COM function call but the data does not change.

My c# function is declared as

void GetData(ref MyData data);

MyData is a struct, and the entry in the tlh file is generated as

  virtual HRESULT __stdcall GetData (
    /*[in,out]*/ struct MyData * data ) = 0;

In the python script I declare

self.myData = win32com.client.Record("MyData", self.myComServerObj)

And call the function

self.myComServerObj.GetData(self.myData)

But the data items in self.myData remain unchanged following the function call.

I can debug the function call in the server side and confirm that the data is changing and can also assign test values at the client side and confirm that these are being received by the server. i.e. the struct parameter works okay as an [In] parameter but not an [out] parameter.

I can also confirm that the function works well with a 'C' COM client program. Can anyone help?

Thanks.

denfromufa
  • 5,610
  • 13
  • 81
  • 138
user5265160
  • 409
  • 1
  • 8
  • 19
  • In pythonnet the out and ref parameters are returned in the output – denfromufa Jul 04 '17 at 10:06
  • Hi, do you mean by return value? If so I tried calling "self.myData= self.myComServerObj.GetData()" but got "com_error: (-2147024809, 'The parameter is incorrect.', None, None)" I also tried "self.myData=self.myComServerObj.GetData(self.myData )" but this produced the same output as before. – user5265160 Jul 04 '17 at 12:11
  • You are using pywin32, I was referring to pythonnet. I'm not sure if pywin32 supports this. – denfromufa Jul 04 '17 at 13:42

0 Answers0