"Hello World" is the first program one usually writes when learning a new programming language.
Do you have any ActiveX on the C++ without ATL and MFC? I wrote this template for you.
You can make DLL with your ActiveX and use its.
Project map:
HelloWorld (actvex.cpp, activex.dll, activex.bat)
|
+-- common (classes.h, spisok.h, functions.h)
|
+-- objects (classfactory.h, object.h, methods.h, connect.h)
|
+-- Test (test.js)
How to make new ActvieX?
- You must change GUID and ProgID in the activex.cpp file:
DEFINE_GUID( CLSID_obj, 0x9ACBF10A, 0xECE2, 0x4F01, 0x90,
0x5B, 0x13, 0x84, 0xEC, 0x0F, 0x82, 0x06);
const char *pDescription = "This is Hello World in ActiveX";
const char *PROGID = "Hello.World";
- You must write the your functions in the methods.h file. For example:
// HelloWorld(S,I)
HRESULT HelloWorld(VARIANTARG* pArg,
VARIANT FAR* pRes, WORD wFlags, HRESULT hr)
{ if (FAILED(hr)) return hr;
UINT uType = (UINT)pArg[0].n1.n2.n3.lVal;
BSTRtoCHAR* pA = new BSTRtoCHAR(pArg[1].n1.n2.n3.bstrVal);
pRes->n1.n2.vt = VT_I4; // The return value
/* The MessageBox function creates, displays, and operates
a message box. The message box contains an
application-defined message and title, plus any
combination of predefined icons
and push buttons. */
pRes->n1.n2.n3.lVal = MessageBox(NULL, pA->sz,
"Hello World as ActiveX", uType);
delete pA;
return S_OK;}
- You must connect your function(s) on the ActiveX object in the connect.h file.
pObj->AddItem("HelloWorld", "SI", HelloWorld);
// ... next
- "HelloWorld" - the external name for method (property)
- "SI" - the arguments mask (S-string, I-integer, B-boolean)
- HelloWorld - the funtion pointer
- That's all
How to register new ActiveX on the computer?
You can use the Regsvr32 tool (Regsvr32.exe) to register and unregister
object linking and embedding (OLE) controls such as ActiveX Controls (DLL)
files that are self-registerable.
- Register ActiveX on the computer:
- regsvr32.exe activex.dll
- Unregister:
- regsvr32.exe /u activex.dll
How to check new ActvieX?
You can use the WSH subsystem Windows 98 and high. The shell wscript.exe
in the %System32% folder:
wscript.exe test.js
// JScript (javascript) test.js
var activex = new ActiveXObject("Hello.World");
var answer = activex.HelloWorld("Hello World !!!!", 50);
WScript.Echo(answer);
I used the "Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland".
Will you use my template? Yes (Download)
|