Jump to content

problem with: COM method with structures as arguments


swieru
 Share

Recommended Posts

Hello,

I am trying to write very basic script to use COM object. It is a specific object allowed to communication with software on the industrial controller.

I can create reference to a COM object by function ObjCreate. Thanks to ObjectName function I can read all information about object. Problem is that, I can trigger (only) one method of this object, named Disconnect().

When I want to use the other method instead of Disconnect(), for example, ReadValueN I have problem with arguments for this method. I tryed many variants, combinations, without positive result. My error monitoring function (for COM errors) reports: "Bad variable types" or "Type mismath".

I studied many examples, many documentations but I have no idea how it should be.

Below is description for method, data etc based on OLE/ COM Object Viewer.

long ReadValueN(

     [in] long TARGET_id,

     [in] PARAM_DEF* pParamDef,

     [out] BUFFER* pResBuffer);
typedef struct tagPARAM_DEF{

     unsigned char Param1;

     unsigned char Param2;

     unsigned char Param3;

     unsigned char ParamT[8];

     short Number;

     unsigned char ValueF;

     unsigned char ValueD;

} PARAM_DEF;


typedef struct tagBUFFER{

     unsigned char BuffA1;

     unsigned char BuffA2;

     unsigned char BuffA3;

     unsigned char BuffTable[256];

} BUFFER;
$structParamDef = DllStructCreate("byte; byte; byte; byte[8]; short; byte; byte")
$structBuffer = DllStructCreate("byte; byte; byte; byte[256]")

$response = $myObject.ReadValueN(0, DllStructGetPtr($structParamDef), DllStructGetPtr($structBuffer))

;$response = $myObject.Disconnect() ; is working

Could someone write me what is wrong and how it should be? And especially - why?

thanks in advanced

Link to comment
Share on other sites

If you provide referency for the object you're using maybe should be easy to help you.

 

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...