V2 version access (V1 version) no problem
but cannot create
I carry on to this point can not continue
I saw that the last item in the reply was also a request for V2 version
Code: Select all
obj := ActiveObject()
ObjRegisterActive(obj, "{6B39CAA1-A320-4CB0-8DB4-352AA81E460E}")
Persistent
OnExit(Revoke)
ObjRegisterActive(Object, CLSID, Flags := 0) {
static cookieJar := Map()
if (!CLSID) {
if !(cookie := cookieJar.Has(Object)) || (cookie := cookieJar.Delete(Object)) != ""
DllCall("oleaut32\RevokeActiveObject", "uint", cookie, "ptr", 0)
return
}
if cookieJar.Has(Object)
throw Error("Object is already registered", -1)
_clsid := Buffer(16, 0)
if (hr := DllCall("ole32\CLSIDFromString", "wstr", CLSID, "ptr", _clsid)) < 0
throw Error("Invalid CLSID", -1, CLSID)
hr := DllCall("oleaut32\RegisterActiveObject", "ptr", &Object, "ptr", _clsid, "uint", Flags, "uint*", &cookie, "uint")
if (hr < 0)
throw Error(format("Error 0x{:x}", hr), -1)
cookieJar[Object] := cookie
}
Revoke(A_ExitReason, ExitCode)
{
ObjRegisterActive(obj, "")
ExitApp()
}
class ActiveObject {
Message(Data) {
ToolTip("Received message: " Data)
return 42
}
}