Jump to content

ObjCreateInterface with custom object


Recommended Posts

I have tryed to compile this "com object" and then use with AutoIt3 but not work: "err.number 0x80020006.

How to do?

#include-once

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

Local Const $sCLSID_TaskbarList = "{7233b105-bc01-41ff-b72e-582c5954b76d}"
    Local Const $sIID_ITaskbarList = "{702d63b3-d7d1-4f17-ab11-2f2ed770fdc8}"
Local Const $sTagITaskbarList = 'SetString(wstr:cdecl);wstr:cdecl GetString();'


Local $oIExample = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
    
$a=$oIExample.SetString("Abc")
msgbox(0,@error,$a)
$a=$oIExample.GetString()
;.GetRootElement.CurrentClassName
exit
msgbox(0,0,$a)

Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 

Edited by Ontosy
Link to comment
Share on other sites

You are welcome. Great to see so much interest in this topic. There is a whole series of a total of 8 articles about COM objects. They are all named "Com in plain C, Part n", where n is 1 - 8. You can find the articles at codeproject.com. This guy Jeff Glatt seems to know what he is talking about, and he also knows how to explain it.

In "Com in plain C, Part 2" the IDispatch interface is added to the object which make it possible to create the object in a scripting language. In AutoIt you can create the object with the ObjCreate command.

Link to comment
Share on other sites

I don't know. I skimmed through the articles relatively quickly. I have not looked at the code. But I'm almost sure that it'll all work. Also in AutoIt. The articles seem pretty convincing.

Link to comment
Share on other sites

  • 7 months later...

The interface description strings are specific for AutoIt. This means that AutoIt programmers have created all the existing description strings themselves.

There are created several hundred interface objects and there are created interface description strings for all these objects. If you're lucky a description string does already exists for the interface you need. Search the forums.

If a description string does not exists for your interface, you have to create it yourself. You create the description string from information you find in C/C++ header files. For ITaskbarList interface you find the information in ShObjIdl.h included in Windows SDK.

Before you start creating a description string you should compare existing description strings with information in header files. In that way you can figure out which AutoIt data types matches the C/C++ data types.

And you can always ask questions in this forum.

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...