Jump to content
Sign in to follow this  
funkey

Help with interface description with COM object

Recommended Posts

funkey

Can someone help me with interface description with following COM object please?

; Class Identifiers
Global Const $CLSID_PVSS00COMLib_ComManager = "{A2E83F96-CD50-4679-A541-4CF315A51471}"
; Interface Identifier
Global Const $IID_PVSS00COMLib_IComManager = "{A4FC62C7-368A-44B1-9AEE-DDCE6DB6CE75}"

Global Const $sTag_PVSS00COMLib_IComManager = ""    ;??

#cs
' Interface Name  : IComManager
' Description     : IComManager Interface
' Class Name      : ComManager
' ClassID         : $CLSID_PVSS00COMLib_ComManager
' ProgID          : $PROGID_PVSS00COMLib_ComManager
' Version ProgID  : $PROGID_PVSS00COMLib_ComManager1
INTERFACE IComManager $IID_PVSS00COMLib_IComManager
    INHERIT IDISPATCH

    METHOD Init <1> (BYVAL sCmdLine AS STRING)
    METHOD getLicense <2> (BYREF IN strLicenseApi AS STRING, BYREF iMaxLicense AS LONG)
    PROPERTY GET isConnected <3> () AS LONG
    METHOD dpSet <4> (BYVAL vDpName AS VARIANT, BYVAL vValue AS VARIANT)
    METHOD dpGet <5> (BYVAL vDpName AS VARIANT, BYREF vValue AS VARIANT)
    METHOD dpConnect <6> (BYVAL vIdent AS VARIANT, BYVAL vDpName AS VARIANT, OPT BYVAL boWantAnswer AS LONG)
    METHOD dpDisconnect <7> (BYVAL vDpName AS VARIANT)
    METHOD dpGetPeriod <8> (BYVAL dtFrom AS DOUBLE, BYVAL dtTo AS DOUBLE, BYVAL lCount AS LONG, BYVAL vDpName AS VARIANT, _
        BYREF vValues AS VARIANT, BYREF vTimes AS VARIANT, BYREF vTypes AS VARIANT)
    METHOD dpGetAsynch <9> (BYVAL dtTime AS DOUBLE, BYVAL vDpName AS VARIANT, BYREF vValues AS VARIANT)
    METHOD dpQuery <10> (BYVAL sQuery AS STRING, BYREF avResult AS VARIANT)
    METHOD dpTypes <11> (BYVAL sPattern AS STRING, BYREF asDpType AS DWORD)
    METHOD dpNames <12> (BYVAL sDpPattern AS STRING, BYVAL sDpType AS STRING, BYREF asDpName AS DWORD)
    METHOD dpElementType <13> (BYVAL sDp AS STRING) AS LONG
    METHOD dpGetDescription <14> (BYVAL vDpName AS VARIANT, OPT BYVAL iMode AS LONG) AS VARIANT
    METHOD dpGetAlias <15> (BYVAL vDpName AS VARIANT) AS VARIANT
    METHOD dpGetFormat <16> (BYVAL vDpName AS VARIANT) AS VARIANT
    METHOD dpGetUnit <17> (BYVAL vDpName AS VARIANT) AS VARIANT
END INTERFACE
#ce

Global $oPVSS = ObjCreateInterface($CLSID_PVSS00COMLib_ComManager, $IID_PVSS00COMLib_IComManager, $sTag_PVSS00COMLib_IComManager)

I hope it is possible.

Thanks in advance.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
trancexx

It says it inherits from IDispach. Does that mean it's dual interfaced? If yes then you don't need interface description.

First check something like this:

$oComManager = ObjCreateInterface($CLSID_PVSS00COMLib_ComManager, $IID_PVSS00COMLib_IComManager)
$oComManager.Init("sCmdLine") ;<- check if error occurs

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
funkey

Yes, an error ocurs :)

$oPVSS.Init("-currentproj")     ;!>14:25:14 AutoIT3.exe ended.rc:259

I don't know if it is dual interfaced, I am new with COM, sorry.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
trancexx

Then first thing you do is add COM error handler. ObjEvent function inside the help file has an example.

edit: then post what you get.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
funkey

I hope this is right, but AutoIt is crashing and do not close correct.

; Class Identifiers
Global Const $CLSID_PVSS00COMLib_ComManager = "{A2E83F96-CD50-4679-A541-4CF315A51471}"
; Interface Identifier
Global Const $IID_PVSS00COMLib_IComManager = "{A4FC62C7-368A-44B1-9AEE-DDCE6DB6CE75}"

Global Const $sTag_PVSS00COMLib_IComManager = "Init none(str);getLicense none(str*;long*)"  ;??

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")



#cs
' Interface Name  : IComManager
' Description     : IComManager Interface
' Class Name      : ComManager
' ClassID         : $CLSID_PVSS00COMLib_ComManager
' ProgID          : $PROGID_PVSS00COMLib_ComManager
' Version ProgID  : $PROGID_PVSS00COMLib_ComManager1
INTERFACE IComManager $IID_PVSS00COMLib_IComManager
    INHERIT IDISPATCH

    METHOD Init <1> (BYVAL sCmdLine AS STRING)
    METHOD getLicense <2> (BYREF IN strLicenseApi AS STRING, BYREF iMaxLicense AS LONG)
    PROPERTY GET isConnected <3> () AS LONG
    METHOD dpSet <4> (BYVAL vDpName AS VARIANT, BYVAL vValue AS VARIANT)
    METHOD dpGet <5> (BYVAL vDpName AS VARIANT, BYREF vValue AS VARIANT)
    METHOD dpConnect <6> (BYVAL vIdent AS VARIANT, BYVAL vDpName AS VARIANT, OPT BYVAL boWantAnswer AS LONG)
    METHOD dpDisconnect <7> (BYVAL vDpName AS VARIANT)
    METHOD dpGetPeriod <8> (BYVAL dtFrom AS DOUBLE, BYVAL dtTo AS DOUBLE, BYVAL lCount AS LONG, BYVAL vDpName AS VARIANT, _
        BYREF vValues AS VARIANT, BYREF vTimes AS VARIANT, BYREF vTypes AS VARIANT)
    METHOD dpGetAsynch <9> (BYVAL dtTime AS DOUBLE, BYVAL vDpName AS VARIANT, BYREF vValues AS VARIANT)
    METHOD dpQuery <10> (BYVAL sQuery AS STRING, BYREF avResult AS VARIANT)
    METHOD dpTypes <11> (BYVAL sPattern AS STRING, BYREF asDpType AS DWORD)
    METHOD dpNames <12> (BYVAL sDpPattern AS STRING, BYVAL sDpType AS STRING, BYREF asDpName AS DWORD)
    METHOD dpElementType <13> (BYVAL sDp AS STRING) AS LONG
    METHOD dpGetDescription <14> (BYVAL vDpName AS VARIANT, OPT BYVAL iMode AS LONG) AS VARIANT
    METHOD dpGetAlias <15> (BYVAL vDpName AS VARIANT) AS VARIANT
    METHOD dpGetFormat <16> (BYVAL vDpName AS VARIANT) AS VARIANT
    METHOD dpGetUnit <17> (BYVAL vDpName AS VARIANT) AS VARIANT
END INTERFACE
#ce

Global $oPVSS = ObjCreateInterface($CLSID_PVSS00COMLib_ComManager, $IID_PVSS00COMLib_IComManager);, $sTag_PVSS00COMLib_IComManager)


$oPVSS.Init("-currentproj")     ;!>14:25:14 AutoIT3.exe ended.rc:259

Global $strLicenseApi, $iMaxLicense
;~ $oPVSS.getLicense($strLicenseApi, $iMaxLicense)

;~ ConsoleWrite($strLicenseApi & @CR)

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

Here is a description to COM syntax: http://www.powerbasic.com/support/help/pbcc/what_does_an_interface_look_like_.htm


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
trancexx

It shouldn't crash as far as AutoIt is concerned. Are you sure object is created correctly (outside AutoIt). Whose server is that? Did you built it? Are you the dev? If yes then check one more time if you have done everything correctly making the interface of dual type.

Looks like it inherits from IDispatch but it's not dual or misses implementation for dispatch methods.


♡♡♡

.

eMyvnE

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
Sign in to follow this  

  • Similar Content

    • Bilgus
      By Bilgus
      ; NetFirewallPolicy2 COM UDF Library for AutoIt3
      ; AutoIt Version : 3.3.14.5
      ; Description ...: Windows Firewall Policy2 Interface, Provides access to the firewall policy for Windows Vista+
      Including Test Script 
      _NetFw_Get_CurrentProfileTypes                           Retrieves the currently active firewall profile(s) _NetFw_Get_FirewallEnabled                               Indicates whether a firewall is enabled locally _NetFw_Put_FirewallEnabled                               Specifies whether a firewall is enabled locally _NetFw_Get_ExcludedInterfaces                            Indicates a list of interfaces on which firewall settings are excluded _NetFw_Put_ExcludedInterfaces                            Specifies a list of interfaces on which firewall settings are excluded _NetFw_Get_BlockAllInboundTraffic                        Indicates whether the firewall should not allow inbound traffic _NetFw_Put_BlockAllInboundTraffic                        Specifies whether the firewall should not allow inbound traffic _NetFw_Get_NotificationsDisabled                         Indicates whether interactive firewall notifications are disabled _NetFw_Put_NotificationsDisabled                         Specifies whether interactive firewall notifications are disabled _NetFw_Get_UnicastResponsesToMulticastBroadcastDisabled  Indicates whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Put_UnicastResponsesToMulticastBroadcastDisabled  Specifies whether the firewall should not allow unicast responses to multicast and broadcast traffic _NetFw_Get_Rules                                         Retrieves the interface to collection of firewall rules _NetFw_Get_ServiceRestriction                            Retrieves the interface used to access the Windows Service Hardening store _NetFw_EnableRuleGroup                                   Enables or disables a specified group of firewall rules _NetFw_IsRuleGroupEnabled                                Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_RestoreLocalFirewallDefaults                      Restores the local firewall configuration to its default state _NetFw_Get_DefaultInboundAction                          Indicates the default action for inbound traffic _NetFw_Put_DefaultInboundAction                          Specifies the default action for inbound traffic _NetFw_Get_DefaultOutboundAction                         Indicates the default action for outbound traffic _NetFw_Put_DefaultOutboundAction                         Specifies the default action for outbound traffic _NetFw_Get_IsRuleGroupCurrentlyEnabled                   Determines whether a specified group of firewall rules are enabled or disabled for the current profile _NetFw_Get_LocalPolicyModifyState                        Determines if adding or setting a rule or group of rules will take effect in the current firewall profile  
      UDF:
      Test Script:
       
    • Bilgus
      By Bilgus
      I was Playing around With AutoIt this evening and wondered how hard it would be to get typeinfo like the COM Viewers do only using AutoIt
      Turns out it was pretty easy.
      A Few Notes:
      CAarray info is unfinished I didn't have any objects to test it on so I left it Limited.
      The Object must have IDispatch exposed (ITypeInfo is derivative)
      Its Just a proof of concept Run with it but don't carry scissors
      ITypeInfoCOM.au3
      ITypeInfoTest.au3
       
      Output IWebBrowserApp
       
      Output ObjCreate(MediaPlayer.MediaPlayer.1)
       
    • Bilgus
      By Bilgus
       IGroupPolicyObject interface
      ;;IGroupPolicyObject #RequireAdmin #include-once #include <WinAPIConstants.au3> ; $S_OK #include <WinAPIReg.au3> ;_WinAPI_GetRegKeyNameByHandle Global Enum $GPO_SECTION_ROOT = 0x0, $GPO_SECTION_USER, $GPO_SECTION_MACHINE Global Enum $GPO_OPEN_LOAD_REGISTRY = 0x1, $GPO_OPEN_READ_ONLY Global Enum $GPO_OPTION_DISABLE_USER = 0x1, $GPO_OPTION_DISABLE_MACHINE Global Enum $GPOTypeLocal = 0x0, $GPOTypeRemote, $GPOTypeDS, $GPOTypeLocalUser, $GPOTypeLocalGroup Global Const $sCLSID_GroupPolicyObject = "{EA502722-A23D-11D1-A7D3-0000F87571E3}" Global Const $sIID_IGroupPolicyObject = "{EA502723-A23D-11D1-A7D3-0000F87571E3}" Global Const $dtag_IGroupPolicyObject = _ "New hresult(wstr;wstr;dword);" & _ ; Creates a new GPO in the Active Directory with the specified display name. "OpenDSGPO hresult(wstr;dword);" & _ ; Opens the specified GPO and optionally loads the registry information. "OpenLocalMachineGPO hresult(dword);" & _ ; Opens the default GPO for the computer and optionally loads the registry information. "OpenRemoteMachineGPO hresult(wstr;dword);" & _ ; Opens the default GPO for the specified remote computer and optionally loads the registry information. "Save hResult(bool;bool;ptr;ptr);" & _ ; Saves the specified registry policy settings to disk and updates the revision number of the GPO. "Delete hresult();" & _ ; Deletes the GPO. "GetName hResult(wstr;int);" & _ ; Retrieves the unique name for the GPO. "GetDisplayName hResult(wstr;int);" & _ ; Retrieves the display name for the GPO. "SetDisplayName hresult(wstr);" & _ ; Sets the display name for the GPO. "GetPath hResult(wstr;int);" & _ ; Retrieves the path to the GPO. "GetDSPath hresult(dword;wstr;int);" & _ ; Retrieves the Active Directory path to the root of the specified GPO section. "GetFileSysPath hresult(dword;wstr;int);" & _ ; Retrieves the file system path (UNC format) to the root of the specified GPO section. "GetRegistryKey hresult(dword;handle);" & _ ; Retrieves a handle to the root of the registry key for the specified GPO section. "GetOptions hResult(dword*);" & _ ; Retrieves the options for the GPO. "SetOptions hresult(dword;dword);" & _ ; Sets the options for the GPO. "GetType hResult(dword*);" & _ ; Retrieves type information for the GPO being edited. "GetMachineName hResult(wstr;int);" & _ ; Retrieves the computer name of the remote GPO. "GetPropertySheetPages hresult(ptr;uint*);" ; Retrieves the property sheet pages associated with the GPO. Test() Func Test() Local $iResult Local $oIGroupPolicy Local $aGpoType[5] = ["Local", "Remote", "Active Directory", "LocalUser", "LocalGroup"] $oIGroupPolicy = ObjCreateInterface($sCLSID_GroupPolicyObject, $sIID_IGroupPolicyObject, $dtag_IGroupPolicyObject) While True If Not IsObj($oIGroupPolicy) Then ConsoleWrite("Failed To Retrieve Interface") $iResult = $E_NOINTERFACE ExitLoop Else ConsoleWrite("Success: " & ObjName($oIGroupPolicy, 1) & @CRLF) EndIf Local $sLoc, $sPath, $sName, $iType $tKey = DllStructCreate("handle hKey") $iResult = $oIGroupPolicy.OpenLocalMachineGPO(BitOR($GPO_OPEN_LOAD_REGISTRY, $GPO_OPEN_READ_ONLY)) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetDisplayName($sLoc, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetName($sName, 65535) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sLoc & " : " & $sName & @CRLF) $iResult = $oIGroupPolicy.GetPath($sPath, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sPath & @CRLF) $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite("Type: " & $aGpoType[$iType] & @CRLF) $iResult = $oIGroupPolicy.GetRegistryKey($GPO_SECTION_USER, DllStructGetPtr($tKey)) If $iResult <> $S_OK Then ExitLoop ConsoleWrite(_WinAPI_GetRegKeyNameByHandle(DllStructGetData($tKey, "hKey")) & @CRLF) ExitLoop WEnd Return SetError($iResult, 0, ($iResult = $S_OK)) EndFunc ;==>Test Note: Not well tested..
    • Fenzik
      By Fenzik
       Hello all"
      I have curious problem with com object implementation of Sapi 5.1.
      In some cases }Some Voice engines] the metods for retrieve the voice parameters fails with error :Member not exists:.
      But the Retrieved Voice object can speak the given text, so It exists and work.
      Example of this type of Engine can be this one: http://download.kobavision.be/KobaSpeech3/KobaSpeech 3 With Vocalizer Serena - English (Great Britain).exe (can work as demo)
      So my question is> Is there some way to workaround or solve this issue?
      What i tryed:
      1. Typical use of Sapi.spvoice object:
      $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
       
        $spvoice = ObjCreate("sapi.spvoice")
      for $voice in $spvoice.getvoices()
        msgbox(0, "Voice", $voice.getdescription())
      next
      Func MyErrFunc()
      $HexNumber = hex($oMyError.number, 8)
      Msgbox(0,"","We intercepted a COM Error !" & @CRLF &"Number is: " & $HexNumber & @CRLF &"Windescription is: " & $oMyError.windescription)
      SetError(1)
      Endfunc

      2. Implement workaround based on Nvda Screen reader sapi5 Library at https://github.com/nvaccess/nvda/blob/master/source/synthDrivers/sapi5.py
      Thys code in Pascal should work, so i tryed to reproduce it in Autoit.
      Pascal code just as example:
                   SOTokens:=SpVoice.GetVoices('','');
                   for i:=0 to SOTokens.Count-1 do
                   try
                        SOToken:=SOTokens.Item(I); s:=SOToken.GetDescription(0);
      end
      In Autoit I tryed it like this:
      $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler
        $spvoice = ObjCreate("sapi.spvoice")
      for $i = 0 to $spvoice.getvoices.count-1
      $name = $spvoice.getvoices.item($i).getdescription
      msgbox(0,"Voice", $name)
      next
      Func MyErrFunc()
      $HexNumber = hex($oMyError.number, 8)
      Msgbox(0,"","We intercepted a COM Error !" & @CRLF &"Number is: " & $HexNumber & @CRLF &"Windescription is: " & $oMyError.windescription)
      SetError(1)
      Endfunc
      Both of this methods returning same Error ("Member not exists.").
      Thanks a lot for help.
      Znefyg
    • gillesg
      By gillesg
      Hello,
       
      Is there a way to get all the properties and method of a COM object thru Autoit.
      I am looking in a way of display the imbricated structure of object and method.
       
      Example of COm objects are "itunes.application", "Shell.application" and so on.
      The idea is to have a code looking like
      $objtobrowse = objcreate("itunes.application") if isobj($objtobrowse) then $colItems = $objtobrowse.buildinproperty For $objItem In $colItems ConsoleWrite($objItem.<Name> & " - " & $objItem.<Value> & @CRLF) Next EndIf  
×