Writing a simple ActiveX control for IE that has one method

I am learning how to write an ActiveX scripted control. My goal is to have a tiny control that can check if something is installed on the system. What i have done so far:

  • Create an MFC ActiveX Management Project in VS2008
  • Add some β€œscript-safe” bits that I found here .
  • Extend IDL to provide my IsInstalled method, which now unconditionally returns TRUE (but will later read some registry keys.)
  • Create a control and run regsvr32. I confirmed that it appears in HKEY_CLASSES_ROOT, and when I instantiate the object, the Locals panel in IE Developer Tools shows that the object is of type _D [my plugin name]. Not only that, but my IsInstalled () method appears under this object.

However, when I call IsInstalled (), I just can't get it to work:

JScript Debugger - gap in JScript runtime error - (n http://img138.imageshack.us/img138/1586/whycomwhy.png

I'm at a loss. I also tried to make the IsInstalled property instead of the method, using VARIANT_BOOL instead of boolean instead of BOOL in IDL, you will name it.

Here are the relevant code excerpts.

Title:

afx_msg VARIANT_BOOL IsInstalled();

Implementation:

afx_msg VARIANT_BOOL
CMyAXCtrl::IsInstalled()
{
   return TRUE;
}

Dispatch Card:

BEGIN_DISPATCH_MAP(CMyAXCtrl, COleControl)
   DISP_FUNCTION_ID(CMyAXCtrl, "IsInstalled", dispidIsInstalled, IsInstalled, VT_BOOL, VTS_NONE)
END_DISPATCH_MAP()

Sending part of IDL:

   [ uuid(6B662202-CF13-4144-AA33-C3FEE9C2C962),
      helpstring("Dispatch interface for My Control")]
   dispinterface _Daxplugin
   {
   properties:
   methods:
      [id(1)] VARIANT_BOOL IsInstalled();
   };

- , , . . !

+5
2

. OLE Automation HRESULT, out .

[id(1)] HRESULT IsInstalled(VARIANT_BOOL* p);

TRUE!= VARIANT_TRUE, VARIANT_TRUE, -1 1.

, , :)

+3

IObjectSafety ( ).

regsvr32 ?

, . , {7DD95802-9882-11CF-9FA9-00AA006C42C4} (Safe for Initialization) {7DD95801-9882-11CF-9FA9-00AA006C42C4}(Safe For Scripting) .

IObjectSafety, .

0

All Articles