Can active x functions be used without gui???

Can active x functions be used without gui???
Yes.
class CIdeaFG : public CWnd
{
protected:
DECLARE_DYNCREATE(CIdeaFG)
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0x25647545, 0x37D5, 0x11D5, { 0xBF, 0x9B, 0x0, 0x50, 0xBA, 0xD3, 0x62, 0xD7 } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
}

BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
its in an mfc application i want to use it in an console based win 32 application can u tell me how???
All that MFC is irrelevant. Which ActiveX control are you trying to use? All you need is the CLSID and CoCreateInstance(). The control will function appropriately even if not placed inside an OLE container. Of course, it won't be visible, but calling its methods should work OK.

If the control requires a license, then the process of creating it is a bit different, but usage-wise is exactly the same.

One more time: COM is not a simple topic. If you are going to use COM frequently, do the right thing: Learn it appropriately. If you are expert in C++ (the language), pick up Don Box's book. It is the single most amazing book on COM that I have ever read, but you need to know C++ or you'll be lost.
Sir the above code is from sdk that i will use in my project and want to use active x function of that sdk,sir the CLSID is given above,now can u guide me what steps i have to take and after which line of code i should write that.
In order to create an ActiveX object that requires a license, you use CoGetClassObject() (http://msdn.microsoft.com/en-us/library/ms684007(VS.85).aspx ) to obtain a pointer to the class factory object. Request the interface IClassFactory2 by means of using the IID IID_IClassFactory2. Then you can use the method CreateInstanceLic() (http://msdn.microsoft.com/en-us/library/ms694342(VS.85).aspx ) to create the licensed copy of the object.

And where does the license BSTR come from? From a call to RequestLicKey() (http://msdn.microsoft.com/en-us/library/ms686578(VS.85).aspx ) on a PC with the license installed.

So create a new, very simple console project, then use RequestLickKey() to obtain the key (run it in a PC with a license for the component), then save that key, say, to a text file.

Now go back to your original console project and use that key in the call to CreateInstanceLic(). After this, use the ActiveX object as you see fit.

I cannot go any further. Good luck.
Sir its does not require any license the CLSID is already mentioned in the code...
Then just use CoCreateInstance() with that CLSID. It is a single function call and you get the pointer to the interface that you want.
sir will it be like this:-
CoCreateInstance(clsid,NULL,0x4,"SIR WHAT WILL BE NEXT TWO");
Google up "c++ cocreateinstance example" (no quotation marks). The second result has a small section called Object Basics. It shows how to use CoCreateInstance().

You definitely need to stop being so needy and learn to get around in the Internet.
It depends on whatever interface that sdk implements.
The one from code project????
sir i am needy as i have to submit my project...
sir thats the main problem where to get the interface???
I don't understand the sdk developers, how should I use their com api while they don't declare the clsid and interface of their component?

funny guys
The documentation of the ActiveX should say. It is the interface that defines the methods you want to call.

Don't know which one? Options:

1. Contact the manufacturer of the ActiveX object.
2. Use OLE Viewer to read the ActiveX's type library.
3. LEARN COM ALREADY.
The sdk must have a header file with interface definitions. If it was called, let's say IExample, it will be like this:
1
2
3
IExample *pIex;
HRESULT hr = 0;
			hr = CoCreateInstance ( CLSID_IExample,  NULL, CLSCTX_INPROC_SERVER, IID_IExample, (void**)&pIex);
header files i have already pasted above in which they have used clsid
Topic archived. No new replies allowed.