swieru

problem with: COM method with structures as arguments

2 posts in this topic

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

Share this post


Link to post
Share on other sites



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

 

Saludos

Share this post


Link to post
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

  • Similar Content

    • Javik
      By Javik
      Is there a way to read data directly from the Windows Component Object Model (COM) interface?
      I am trying to make a really simple disk space reporter tool for accounts on an Active Directory domain, to read the disk quota limit for the logged on user's home directory, and report how much disk space they are currently using.
      ,
      MSDN:  IDiskQuotaUser interface
      https://msdn.microsoft.com/en-us/library/windows/desktop/aa365033(v=vs.85).aspx
      GetQuotaLimit
      GetQuotaUsed
       
       
    • WoodGrain
      By WoodGrain
      Hi All,
      I've coded the small script below, but it can't seem to get the instance of Windows Media player as it keeps going to @error, I've not used com objects before so any assistance would be appreciate. I already have WMP open and minimised. I retrieved "WMPlayerApp" from the AutoIT info tool, I've included a copy below.
      I'm using these sources:
      https://msdn.microsoft.com/en-us/library/dd564085.aspx
      https://msdn.microsoft.com/en-us/library/dd564018.aspx
      $oWMP = ObjGet("", "WMPlayerApp") If @error Then MsgBox(0, "Can't get WMP", "Couldn't connect to the WMP instance") Exit EndIf $wmpPlayState = $oWMP.playState MsgBox(0, "Play State", $wmpPlayState) $wmpSongName = $oWMP.currentMedia.name MsgBox(0, "Play State", $wmpSongName) I've also seen references to the below, but I want to get an existing open WMP:
      ObjCreate("wmplayer.OCX") and have looked at the WMP.udf but can't see how it will do either of the functions I've coded above.
       
    • kcvinu
      By kcvinu
      Hi all (Especially @water)
      I wonder how to do this task in word from autoit.
      Assume that i pasted some text into word with this code.
      Local $oWord = ObjGet("","Word.Application") Local $wRangeObj = _Word_DocRangeSet($oWord, 0) Local $data = ClipGet() $wRangeObj.Text = $data $wRangeObj.Font.Bold = True So far so good. Now, i need to enter a new line in word and turn the Font.Bold = False.  
      Currently, i did it with activating the word window and Send() function. But i would like to do it with the help of COM object. How can i do that ? 
    • TheDcoder
      By TheDcoder
      Hello, I found a VB snippet which I would love to use in AutoIt
      strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Process") For Each objItem in colItems Wscript.Echo objItem.Name Wscript.Echo objItem.CommandLine Next Despite my best efforts, I am not able to understand a thing from that piece of code . All I know is that it outputs the Name and Commandline of all the processes currently running (Let's see if I am right).
      Can anyone help me with convert this into AutoIt? Thanks in Advance!
    • soloprt
      By soloprt
      hi  am new and i just started learning autoit
      am starting to do a little program that can help me in my work
      i dont know how to do it correctly : a combobox that shows what com port are connected to devices in the computer and when i choose a port and click on a button called info_port  i want that he desplay in $result the name of the device connected to the choosen com port.
      i want to use this file to help me : CommMG.au3
      thanks
      #include 'CommMG.au3' ;comm ports library Global $result = GUICtrlCreateEdit("", 364, 135, 568, 595) Global $info_port = GUICtrlCreateButton("Info", 291, 85, 56, 25) Global $Port = GUICtrlCreateCombo("", 150, 85, 135, 24) $portlist = _CommListPorts(0) If Not @error = 1 Then For $pl = 1 To $portlist[0] GUICtrlSetData($Port, $portlist[$pl]) Next EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg  
      CommMG.au3