Creates a reference to an object from the given classname/object pointer, interface identifier and description string.
ObjCreateInterface ( "CLSID" , "IID" [,"interface_description", ["flag"]] )
CLSID | Class identifier or object pointer. If this is a class identifier it can be in either ProgID or the string representation of the CLSID. |
IID | String representation of interface identifier. |
interface_description | [可选参数] String describing v-table of the object. Use keyword Default to access IDispatch for dual interfaces. |
flag | [可选参数] Default value is True meaning the object interface inherits from IUnknown. |
Success: | Returns an object. |
Failure: | Returns 0 and sets @error to non-zero. |
Type | Details |
none | no value (only valid for return type - equivalent to void in C) |
byte | an unsigned 8 bit integer |
boolean | an unsigned 8 bit integer |
short | a 16 bit integer |
word, ushort | an unsigned 16 bit integer |
int, long | a 32 bit integer |
bool | a 32 bit integer |
dword, ulong, uint | an unsigned 32 bit integer |
hresult | a 32 bit integer |
int64 | a 64 bit integer |
uint64 | an unsigned 64 bit integer |
ptr | a general pointer (void *) |
hwnd | a window handle (pointer) |
handle | an handle (pointer) |
float | a single precision floating point number |
double | a double precision floating point number |
int_ptr, long_ptr, lresult, lparam | an integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt. |
uint_ptr, ulong_ptr, dword_ptr, wparam | an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt. |
str | an ANSI string (a minimum of 65536 chars is allocated). |
wstr | a UNICODE wide character string (a minimum of 65536 chars is allocated). |
bstr | a composite data type that consists of a length prefix, a data string and a terminator |
variant | a tagged union that can be used to represent any other data type |
idispatch, object | a composite data type that represents object with IDispatch interface |
clsid | 128-bit integer in form of GUID string |
struct | structure created with DllStructCreate() |
* | Add * to the end of another type to pass it by reference. For example "int*" passes a pointer to an "int" type. |
Example()
Func Example()
; Declare the CLSID, IID and interface description for ITaskbarList.
; It is not necessary to describe the members of IUnknown.
Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"
; Create the object.
Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)
; Initialize the iTaskbarList object.
$oTaskbarList.HrInit()
; Run Notepad.
Run("notepad.exe")
; Wait for the Notepad window to appear and get a handle to it.
Local $hNotepad = WinWait("[CLASS:Notepad]")
; Tell the user what to look for.
MsgBox(4096, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")
; Delete the Notepad entry from the Taskbar.
$oTaskbarList.DeleteTab($hNotepad)
; Tell the user to look again.
MsgBox(4096, "", "Look in the Taskbar. There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")
; Close Notepad.
WinClose($hNotepad)
EndFunc ;==>Example