MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / BIF_DECL

Function BIF_DECL

source/script_com.cpp:18–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18BIF_DECL(ComObject_Call) // Formerly BIF_ComObjCreate.
19{
20 ++aParam; // Exclude `this`
21 --aParamCount;
22
23 HRESULT hr;
24 CLSID clsid, iid;
25 for (;;)
26 {
27#ifdef UNICODE
28 LPTSTR cls = TokenToString(*aParam[0]);
29#else
30 CStringWCharFromTChar cls = TokenToString(*aParam[0]);
31#endif
32 // It has been confirmed on Windows 10 that both CLSIDFromString and CLSIDFromProgID
33 // were unable to resolve a ProgID starting with '{', like "{Foo", though "Foo}" works.
34 // There are probably also guidelines and such that prohibit it.
35 if (cls[0] == '{')
36 hr = CLSIDFromString(cls, &clsid);
37 else
38 // CLSIDFromString is known to be able to resolve ProgIDs via the registry,
39 // but fails on registration-free classes such as "Microsoft.Windows.ActCtx".
40 // CLSIDFromProgID works for that, but fails when given a CLSID string
41 // (consistent with VBScript and JScript in both cases).
42 hr = CLSIDFromProgID(cls, &clsid);
43 if (FAILED(hr)) break;
44
45 __int64 punk = 0;
46 if (aParamCount > 1)
47 {
48 hr = CLSIDFromString(CStringWCharFromTCharIfNeeded(TokenToString(*aParam[1])), &iid);
49 if (FAILED(hr)) break;
50 }
51 else
52 iid = IID_IDispatch;
53
54 hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, iid, (void **)&punk);
55 if (FAILED(hr)) break;
56
57 _f_return(new ComObject(punk, iid == IID_IDispatch ? VT_DISPATCH : VT_UNKNOWN));
58 }
59 ComError(hr, aResultToken);
60}
61
62
63BIF_DECL(BIF_ComObjGet)

Callers

nothing calls this directly

Calls 15

TokenToStringFunction · 0.85
ComErrorFunction · 0.85
TokenIsNumericFunction · 0.85
TokenToInt64Function · 0.85
TokenToVarTypeFunction · 0.85
TokenToObjectFunction · 0.85
GetClassTypeInfoFunction · 0.85
TokenSetResultFunction · 0.85
GetObjectPtrPropertyFunction · 0.85
QueryInterfaceMethod · 0.80
MemoryErrorMethod · 0.80
GetTypeInfoMethod · 0.80

Tested by

no test coverage detected