|
I need to develop COM application using C++. Please help me with some complete code samples which I can execute. Also please give some reference to COM resources using C++ on Internet. Thanks in advance.
Nilotpal
Nilotpal
|
|
|
|
|
Hi,
There are some good samples of COM using C++ in MSDN.
Same you may get from MSDN online...
I think Inside-COM by Dale Rogerson is a good book...(in C++) for beginners.
Firoz
|
|
|
|
|
|
hello,
i need a little help.
i have:
1) my ATL COM (lets say A) with MFC support which calls another my ATL COM (lets say B) with MFC which uses ADO(COM)
2) my ATL COM NT service(object C) created by wizard(server type=executable)
and what's my problem?
I can create instance of object A in object C, no problems, object A can create object B, still no problems, BUT there's no way for me to force the object B to pass the Open method of ADO's Connection, i'm still geting 0x80004005 - Unspecified error.
Is there anybody there who could help me, i would really appreaciate that.
thanks a lot in advance
johny flash
|
|
|
|
|
definitely i'm not able to use even directly(without my objects descibed in the message above) ADO(COM) from executable service created with ATL COM AppWizard. Still can't open the connection, method Connection::Open
|
|
|
|
|
I have got ADO working in my NT Service without any problem.
Are you calling ::CoInitialize and CoUnitialize in all your threads. You need to load the OLe libraries in all your threads. ADO requires this as it is a COM Object.
|
|
|
|
|
it's working fine in a standard win32 console application, but not in a service EXE, i'm definitely sure that i'am calling both methods that you've mentioned
|
|
|
|
|
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
void CServiceModule::Run()
{
//only relevant code
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, REGCLS_MULTIPLEUSE);
try{
m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->Open("Provider=MSDASQL;DSN=XXX","","",adConnectUnspecified);
}
catch(_com_error &e){
//catched with 0x80004005 all the time
}
}
|
|
|
|
|
I created a toolbar for IE using the DeskBand ATL Object Wizard 2.0, and now I'm trying to access the IWebBrowser2 object. I specify this in the header:
CComQIPtr<iwebbrowser2, &iid_iwebbrowser2=""> m_spWebBrowser2;
and call these lines:
// Retrieve and store the IWebBrowser2 pointer
m_spWebBrowser2 = pUnkSite;
if (m_spWebBrowser2 == NULL)
return E_INVALIDARG;
But, for some reason unknown to me, m_spWebBrowser2 is always NULL! What am I doing wrong? I'm in the process of learning ATL/COM, so please excuse me if this is a newbie question .
|
|
|
|
|
Here's the code to do it.
CComQIPtr<IServiceProvider> sp = punkSite;
CComPtr<IWebBrowser2> pbrowser;
if ( sp )
sp->QueryService ( IID_IWebBrowserApp, IID_IWebBrowser2, (void**) &pbrowser ); The site doesn't implement IWebBrowser2, but it knows how to get such an interface, so you ask it for that interface with IServiceProvider::QueryService().
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Thank you! It did exactly what I wanted it to do .
|
|
|
|
|
Hi!
I developped a MMC snapin that display an ATL object in the result pane (the one to the right).
The ATL object is a Composite Control. The control is showing ok but there is no functionnality except the buttons. I would like to add a progress bar but it doesnt work.
If anyone knows how to add the progress bar and make it functionnal. Or even better, if anyone knows how to use a CDialog (or anything CWnd based) based class behind that ATL object in the result pane. Help would be very appreciated!
Thanks
Scoob
|
|
|
|
|
My goal: to be able to stop (and start, and stop again, etc...) left- and right-click events from going to Internet Explorer, AND to be able to send left- and right-click events to IE.
My situation: I've already made a toolbar for IE, and am trying to implement the above in this toolbar.
My efforts: I found the FreezeEvents method of IOleControl; would that work for part of what I want to do? If so, how do I implement it? I've gone crazy trying to figure out how to call the FreezeEvents function!
Also remember, I still need to know how to send those mouse click events to IE.
Help would be much appreciated!
|
|
|
|
|
Attache to the events of IE. You will get BeforeNavigate and such. then to simulate them youjust call Navigate2, Refresh, or Stop on the IWebBrowser2 interface. Also they have get_busy to tell if it is currently navigating/refreshing.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Uhhh, those things wouldn't help me a bit, I'm afraid Re-read my message, and you'll see what I mean. Basically, I just need to disable all right- and left-mouse button clicks, within the web site pane of Internet Explorer (disabling it within all of IE would work, too).
Please help! I'll be able to make a killer helper for IE, if I can just get that figured out .
|
|
|
|
|
NM, I figured out how to do it! I just created a MouseProc hook, and returned -1.
|
|
|
|
|
I writed dll via MFCAppWizard(dll) [extention dll] in vc++
and it's works excellent by client program in mfc.
----------------------------------------------------------
Now I need provide the dll for Delphi
So * I created ATL by ATL COM AppWizard (with support mfc)
* I added to it a ATL class (by the wizard , of course)
* I imported function from my mfc DLL as I did at the client program in mfc.
-----------------------------------------------------------
But It is not works !!!!
When I execute this ATL object by client program it does not perform the imported funcyion in run time.
----------------------------------------------------------
Who can help me ??????
|
|
|
|
|
Did u use AFX_MANAGE_STATE() ?
And also u should not try to use the
classes from the MFC dll in the ATL program,
u can only use the functions.
If this does not help, further information
can help me anlayse it.
|
|
|
|
|
I must provide dll that will match to every language !!!
I did exctention dll that works well in vc but NOT in another.
I understood that the best way for me (as beginner at this subject) is to use the Wizard of ATL COM with suppot MFC and importe my mfc dll to it.
When I run it by client program (exe) the atl it works !
but the imported function (ShowDialog) dont performed. WHY ????????
------------------------------------------------------------
My steps:
1. I opened project: ATL COM Wizard. [DLL] [MFC Support]
2. I inserted to the library that created the file : MyMfcDll.dll
and attached to the ATL project the files : MyMfcDll.h , MyMfcDll.lib
3. I Added by wizard ATL class [MyClass] [single] [dual]
4. I added by wizard method [ShowMfcDialog] to IMyClass and fill it so :
___________________________________________
extern "C" __declspec(dllimport) void ShowDialog();
STDMETHODIMP CAtlObj::ShowMfcDialog()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
AfxMessageBox(".....");
ShowDialog();
return S_OK;
}
|
|
|
|
|
I trys now to build ATL without import the MFC DLL that I crated.
So
1. I going to resources and inserting Dialog.
2. I created class dialog::CDialog (possibility ?)
3. I added ATL class - simple.
4. I added to this ATL class object from the class dialog .
5. I added to this ATL class method that doind : dlg.DoModal();
I run it from client program and it is works so :
It shows the dialog of the method of ATL class (in number 5)
But when press OK or Cancel it is crush.
____________________________________________________-
Have I use only in ATL dialog or there are a way to works as I tried (Maybe have I added AFX_MANAGE_STATE somewhere)?
What I need to add in the: () of that ?
|
|
|
|
|
We're making an ATL object to be used in ASP or Visual Basic.
I want to be able to return a BSTR to make it nice and pretty for my VB partner.
Ok ok, we all know that you can say...
///////////////
STDMETHODIMP Foo([out,retval] BSTR outstring)
///////////////
..and have it returned in a variable in the Implementation. (duh)
But can we get this a function in an object to look like:
///////////////
BSTR Foo(BSTR instring);
///////////////
or just something with the emphasis on returning a BSTR in the "real" return parameter place.
"The Master Wang" doesnt have money to buy a COM or ATL book...
and plus I know I'm asking questions from the best!
SHABBA!!
*Please Contact Me if you have a Donation to give to a poor college student who needs money for a engagement ring for the greatest girl in the world.
-~= The (still learning) Master Wang =~-
|
|
|
|
|
If I understand what your asking
STDMETHODIMP Foo([out,retval] BSTR return_string, [out]BSTR out_string)
would get you
BSTR Foo(BSTR instring)
BTW, nice sucking up;)
|
|
|
|
|
Hi,
Actually you can use any data type "Automation Data Types are recomended" to be a return type of any interface's method. But, it's just a recommendation that you use the HRESULT (STDMETHOD macro) as a return type, this return type will give the COM Runtime Environment the ability to return error codes when your component cannot be accessed for any reason. If you don't provide HRESULT as a return type, the COM Runtime Environment cannot return error codes for you.
"If You Know That Your Component Will Live With Its Client On The Same Machine, You Can Ignore HRESULT"
Regards,
ShadiK.
|
|
|
|
|
>..and have it returned in a variable in the Implementation. (duh)
>But can we get this a function in an object to look like:
>///////////////
>BSTR Foo(BSTR instring);
>///////////////
No, COM interfaces can't return a value like you suggest.
The correct (and only way) is as you described,
STDMETHODIMP Foo([out,retval] BSTR* outstring)
Your VB code would then look like,
Dim sTemp
sTemp = Object.Foo
Hope this helps,
Michael
|
|
|
|
|
The solution is simple. In your source file (.cpp) change your function header to this:
STDMETHODIMP_(BSTR) YourClass::Foo(BSTR instring)
and do the same for your (.h) file.
You need to change the entry in the IDL file as well,like the following:
BSTR Foo(BSTR instring);
Rookie Programmer
|
|
|
|