I tried but without success.
I do not see that TensorFloatStatics.Create queries for IIterable interface.
Code: Select all
CreateClass("Windows.AI.MachineLearning.TensorFloat", ITensorFloatStatics := "{DBCD395B-3BA3-452F-B10D-3C135E573FA9}", TensorFloatStatics)
Iterable := IIterable_new()
global Iterator := IIterator_new()
msgbox % DllCall(NumGet(NumGet(TensorFloatStatics+0)+7*A_PtrSize), "ptr", TensorFloatStatics, "ptr", Iterable, "ptr*", TensorFloat) ; TensorFloatStatics.Create
IIterable_new() {
static VTBL := [ "QueryInterface"
, "AddRef"
, "Release"
, "GetIids"
, "GetRuntimeClassName"
, "GetTrustLevel"
, "First" ]
, heapSize := A_PtrSize*10
, heapOffset := A_PtrSize*9
, flags := (HEAP_GENERATE_EXCEPTIONS := 0x4) | (HEAP_NO_SERIALIZE := 0x1)
, HEAP_ZERO_MEMORY := 0x8
hHeap := DllCall("HeapCreate", "UInt", flags, "Ptr", 0, "Ptr", 0, "Ptr")
addr := IIterable := DllCall("HeapAlloc", "Ptr", hHeap, "UInt", HEAP_ZERO_MEMORY, "Ptr", heapSize, "Ptr")
addr := NumPut(addr + A_PtrSize, addr + 0)
for k, v in VTBL
addr := NumPut(RegisterCallback("IIterable_" . v), addr + 0 )
NumPut(hHeap, IIterable + heapOffset)
Return IIterable
}
IIterable_QueryInterface(this, riid, ppvObject)
{
msgbox query IIterable
static IID_IUnknown, IID_IIterable
if (!VarSetCapacity(IID_IUnknown))
{
VarSetCapacity(IID_IUnknown, 16), VarSetCapacity(IID_IIterable, 16)
DllCall("ole32\CLSIDFromString", "WStr", "{00000000-0000-0000-C000-000000000046}", "Ptr", &IID_IUnknown)
DllCall("ole32\CLSIDFromString", "WStr", "{7784427E-F9CC-518D-964B-E50D5CE727F1}", "Ptr", &IID_IIterable)
}
if (DllCall("ole32\IsEqualGUID", "Ptr", riid, "Ptr", &IID_IIterable) || DllCall("ole32\IsEqualGUID", "Ptr", riid, "Ptr", &IID_IUnknown))
{
NumPut(this, ppvObject+0, "Ptr")
IIterable_AddRef(this)
return 0 ; S_OK
}
NumPut(0, ppvObject+0, "Ptr")
return 0x80004002 ; E_NOINTERFACE
}
IIterable_AddRef(this) {
static refOffset := A_PtrSize*8
NumPut(refCount := NumGet(this + refOffset, "UInt") + 1, this + refOffset, "UInt")
Return refCount
}
IIterable_Release(this) {
static refOffset := A_PtrSize*8
, heapOffset := A_PtrSize*9
NumPut(refCount := NumGet(this + refOffset, "UInt") - 1, this + refOffset, "UInt")
if (refCount = 0) {
hHeap := NumGet(this + heapOffset)
DllCall("HeapDestroy", "Ptr", hHeap)
}
Return refCount
}
IIterable_GetIids(this, iidCount, IID)
{
msgbox iid
return
}
IIterable_GetRuntimeClassName(this, className)
{
msgbox class
return
}
IIterable_GetTrustLevel(this, TrustLevel)
{
msgbox TrustLevel
return
}
IIterable_First(this, first)
{
msgbox first
NumPut(Iterator, first+0, 0, "ptr")
return
}
IIterator_new() {
static VTBL := [ "QueryInterface"
, "AddRef"
, "Release"
, "GetIids"
, "GetRuntimeClassName"
, "GetTrustLevel"
, "get_Current"
, "get_HasCurrent"
, "MoveNext"
, "GetMany" ]
, heapSize := A_PtrSize*20
, heapOffset := A_PtrSize*19
, flags := (HEAP_GENERATE_EXCEPTIONS := 0x4) | (HEAP_NO_SERIALIZE := 0x1)
, HEAP_ZERO_MEMORY := 0x8
hHeap := DllCall("HeapCreate", "UInt", flags, "Ptr", 0, "Ptr", 0, "Ptr")
addr := IIterator := DllCall("HeapAlloc", "Ptr", hHeap, "UInt", HEAP_ZERO_MEMORY, "Ptr", heapSize, "Ptr")
addr := NumPut(addr + A_PtrSize, addr + 0)
for k, v in VTBL
addr := NumPut(RegisterCallback("IIterator_" . v), addr + 0 )
NumPut(hHeap, IIterator + heapOffset)
Return IIterator
}
IIterator_QueryInterface(this, riid, ppvObject)
{
msgbox query IIterator
static IID_IUnknown, IID_IIterator
if (!VarSetCapacity(IID_IUnknown))
{
VarSetCapacity(IID_IUnknown, 16), VarSetCapacity(IID_IIterator, 16)
DllCall("ole32\CLSIDFromString", "WStr", "{00000000-0000-0000-C000-000000000046}", "Ptr", &IID_IUnknown)
DllCall("ole32\CLSIDFromString", "WStr", "{FB98034C-86B7-581F-8CD9-5AD0692201A9}", "Ptr", &IID_IIterator)
}
if (DllCall("ole32\IsEqualGUID", "Ptr", riid, "Ptr", &IID_IIterator) || DllCall("ole32\IsEqualGUID", "Ptr", riid, "Ptr", &IID_IUnknown))
{
NumPut(this, ppvObject+0, "Ptr")
IIterator_AddRef(this)
return 0 ; S_OK
}
NumPut(0, ppvObject+0, "Ptr")
return 0x80004002 ; E_NOINTERFACE
}
IIterator_AddRef(this) {
static refOffset := A_PtrSize*18
NumPut(refCount := NumGet(this + refOffset, "UInt") + 1, this + refOffset, "UInt")
Return refCount
}
IIterator_Release(this) {
static refOffset := A_PtrSize*18
, heapOffset := A_PtrSize*19
NumPut(refCount := NumGet(this + refOffset, "UInt") - 1, this + refOffset, "UInt")
if (refCount = 0) {
hHeap := NumGet(this + heapOffset)
DllCall("HeapDestroy", "Ptr", hHeap)
}
Return refCount
}
IIterator_GetIids(this, iidCount, IID)
{
msgbox iid
return
}
IIterator_GetRuntimeClassName(this, className)
{
msgbox class
return
}
IIterator_GetTrustLevel(this, TrustLevel)
{
msgbox TrustLevel
return
}
IIterator_get_Current(this, current)
{
msgbox get_Current
numput(1000, current+0, 0, "int64")
return
}
IIterator_get_HasCurrent(this, hasCurrent)
{
msgbox get_HasCurrent
numput(1, hasCurrent+0, 0, "int") ; true
return
}
IIterator_MoveNext(this, hasCurrent)
{
msgbox MoveNext
numput(0, hasCurrent+0, 0, "int") ; false
return
}
IIterator_GetMany(this, capacity, value, actual)
{
msgbox GetMany
return
}
CreateClass(string, interface, ByRef Class)
{
CreateHString(string, hString)
VarSetCapacity(GUID, 16)
DllCall("ole32\CLSIDFromString", "wstr", interface, "ptr", &GUID)
result := DllCall("Combase.dll\RoGetActivationFactory", "ptr", hString, "ptr", &GUID, "ptr*", Class, "uint")
if (result != 0)
{
if (result = 0x80004002)
msgbox No such interface supported
else if (result = 0x80040154)
msgbox Class not registered
else
msgbox error: %result%
ExitApp
}
DeleteHString(hString)
}
CreateHString(string, ByRef hString)
{
DllCall("Combase.dll\WindowsCreateString", "wstr", string, "uint", StrLen(string), "ptr*", hString)
}
DeleteHString(hString)
{
DllCall("Combase.dll\WindowsDeleteString", "ptr", hString)
}