Author: zfive5 (zhaozidong) email: zfive5@yahoo.com.cn
Recently, overtime is more serious, so I have not written some things. At this time, I realized some things about COM automation because of all kinds of crushing code, "automated" familiar and blurred words, now I suddenly realize it. It is automated. I saw the shadow of reflection in Java, haha
suddenly see the light! ! !
Overtime is over
VC DISPID ID; Guid D1; D1.Data1 = 0; D1.Data2 = 0; D1.Data3 = 0; D1.Data4 [0] = 0; D1.Data4 [1] = 0; D1.Data4 [2] = 0; D1.DATA4 [3] = 0; D1.Data4 [4] = 0; D1.Data4 [5] = 0; D1.Data4 [6] = 0; D1.Data4 [7] = 0;
CLSID CLSID; CLSIDFROMPROGID (L "DADDCTRL.CTLISH", & clsid); CWND * P = New CWnd; P-> CreateControl (CLSID, "A", WS_Visible, CRECT (0, 0, 0), THIS, 1000) Wchar_t * p1 = l "Sayhello"; idispatch * patch; iUnknown * known;
HRESULT hr = E_FAIL; hr = :: CoCreateInstance (clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void **) & known); if (hr == S_OK) {hr = known-> QueryInterface (IID_IDispatch, (void **) & patch ); If (hr == s_ok) {knwn-> release (); hr = patch-> getidsofNames (iiD_null, (lpolestr *) & p1, 1, local_user_default, & id); if (hr == s_ok) {Disprams Disprams; MEMSET (& Dispparams, 0, SizeOf Dispparams);
VARIANT * pvarResult = NULL; EXCEPINFO excepInfo; memset (& excepInfo, 0, sizeof excepInfo); unsigned int id1 = -1; hr = patch-> Invoke (id, d1, 0, DISPATCH_METHOD, & dispparams, pvarResult, & excepInfo, & id1); } Patch-> release ();}} P-> destroyWindow (); delete p;