Returning a value from a method in an ActiveX control
I am creating an ActiveX control that will be used in web pages to query the currently installed version of third party software on a client machine. Only one method, GetVersion, should be presented to the control, which returns the version as an integer. I am very inexperienced with ActiveX and am having trouble with something as simple as returning values from methods correctly. If I use the following declaration in IDL:
[id(1)] void GetVersion();
Connects to the following implementation:
BEGIN_DISPATCH_MAP(CDetectorCtrl, COleControl)
DISP_FUNCTION_ID(CDetectorCtrl, "GetVersion", 1, GetVersion, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
void CDetectorCtrl::GetVersion()
{
MessageBox(L"Test");
}
I can call a method from HTML and see my MessageBox fine.
But if I change the definition / code to:
[id(1)] int GetVersion();
and
BEGIN_DISPATCH_MAP(CDetectorCtrl, COleControl)
DISP_FUNCTION_ID(CDetectorCtrl, "GetVersion", 1, GetVersion, VT_INT, VTS_NONE)
END_DISPATCH_MAP()
int CDetectorCtrl::GetVersion()
{
MessageBox(L"Test");
return 1337;
}
I am getting a crash when calling a method from HTML.
+1
source to share