|
3 steps to reduce (not to avoid completely) interdependencies between COM projects
The basic idea is that interfaces themselves change not every time the implementation modul changes. When you change some code in any source file, the module will be compiled and target binary file wil be linked.
1) Remove project dependencies from external com modules in your solution file.
2) Obtain external interfaces by using #import directive. If your external COM project has .tlb (this is the common case), #import this tlb file, not the target .dll or .exe.
3) (optional. useful for solving cross-dependencies) Collect .idl files of external COM modules in a new project that will be built first during solution build. Exclude those files from build in their native projects.
hallelujah
|
|
|
|
|
hi,
i want to open a popup window of a web page as a simple child window rather than as popup any body can help plz..??
thanx,
sufyan
|
|
|
|
|
Hi,
I am have some problems calling a DLL in embedded Pocket PC. The CoCreateInstance reply a error "Class not registered."
I have already register the DLL in the Pocket PC device and even in the emulator but I still keep getting the same error.
I have a running version for desktop but the same is having problems on embedded. In debug mode, I found that the DLLMain's parameter dwReason is = DLL_PROCESS_DETACH.
Can someone please help me?
Thanks in advance.
|
|
|
|
|
Hello All,
Not to toot my own horn...well, OK...to toot my own horn
You may recall my step-by-step DCOM tutorial for VC6, which I posted at
http://www.codeproject.com/com/HelloTutorial1.asp[^]
The tutorial isn't meant to reveal the underlying theory and gory detail of DCOM itself, just like the Scribble tutorial wasn't exactly meant to tour every nook and cranny of MFC. However, the tutorial shows each step to take to build a very simple DCOM server and client.
People have been asking me to update the tutorial for VS.NET. And, at last, the new tutorial series is in the midst of being written. Check it out at
Step 1: http://www.codeproject.com/useritems/HelloTutorial1NET.asp[^]
The tutorial is written in several "Steps" -- the main parts of the process. Step 1 is linked above, and each Step contains links to every other step.
Do me a favor, and use the rating at the bottom of each step to score that Step, and post to the Steps' message boards with your questions, and also suggestions on how to make a certain Step better etc. I welcome any and all input, and both positive kudos and constructive feedback together are great. Thanks!
Sincerely Yours,
Brian Hart
Department of Physics and Astronomy
University of California, Irvine
-- modified at 4:31 Saturday 31st December, 2005
|
|
|
|
|
I'd like to embed an IE browser control in a window, but suppress the 3D frame and scrollbars.
Using CreateControl() in an MFC project, I've created a WebBrowser2 control, which I then query to get a IWebBrowser2 interface, whose document I query to get an ICustomDoc interface, which I use to call SetUIHandler, passing my own container.
So, basically, I have a container window (subclass of CWnd), which contains the browser control, and then container window implements IDocHostUIHandler in order to implement GetHostInfo() and have it modify some of the flags that control some its appearance (DOCHOSTUIFLAG_NO3DOUTERBORDER and DOCHOSTUIFLAG_SCROLL_NO).
The only mysterious thing is that during runtime, after I call SetUIHandler(), my container window class (the one implementing IDocHostUIHandler) receives only two calls to its QueryInterface, neither of which ask for IDocHostUIHandler! First, it asks for IID_IOleCommandTarget (just after I call SetUIHandler), and later it is asked for {C4D244B0-D43E-11CF-893B-00AA00BDCE1A} which is apparently IDocHostShowUI.
Does this mean I'm going to have to implement these other two interfaces as well?
Could the browser control not be requesting IDocHostUIHandler because of the earlier failures?
Has anyone ever managed to pull off this sort of trick? (Changing embedded (as MFC control CWnd-derivative) browser's appearance)
-- modified at 13:37 Friday 30th December, 2005
|
|
|
|
|
|
Hi, hope someone can help me with this COM access violation on DLL exit...
I have a class (CXmlDom) which wraps MS IXMLDOM COM object to give some XML capability to a DLL. It was based on Tom Archers excellent article "Introducing the XML Document Object Model (DOM)" http://www.codeguru.com/Cpp/misc/misc/article.php/c3707.
The class is used, but not exposed, by dll. The dll has been successfully used in Visual Studio projects in the past.
I tried using the DLL in a new DLL, but now I get access violation on exit.
TestDlg >> NewDll >> OldXmlDll >> CXmlDom
The error occurs (in debug mode) in the destructor of CXmlDom:
_com_ptr_t<_com_IIID<msxml::ixmldomnode,&_guid_2933bf80_7b36_11d2_b20e_00c04f983e60> >::operator=(MSXML::IXMLDOMNode * 0x00000000) line 216 + 3 bytes
_com_ptr_t<_com_IIID<msxml::ixmldomnode,&_guid_2933bf80_7b36_11d2_b20e_00c04f983e60> >::operator=(int 0) line 240
CXmlDom::~CXmlDom() line 702
Based on suggestions on the web, I tried setting the smart pointers IXMLDOMNodePtr and IXMLDOMDocumentPtr to null in ~CXmlDom()
(I had assumed they took care of themselves, being smart).
However, this still gives me access violation on exit, in "pOldInterface->Release();" line 216 of COMIP.h (when it is saving interface)
I am guessing my inexperience with COM and DLLs are leading me to access stuff that has already been destroyed, perhaps due to the use of "nested" dlls.
I tried to use release and detach on smartpointers, but I still get access violations.
Any advice on how to use / unload / release the IXMLDOM COM object in DLLs would be appreciated
(I’m wondering if the COMplicated smart pointers are too smart for me – should never have tried to combine with DLLs )
Thanks
Jens Winslow
|
|
|
|
|
Make sure CoUnitialize() isn't being called before all your smart pointers go out of scope.
|
|
|
|
|
Thanks - I am not calling counitialize deliberetly, but I am guessing it is called indirectly when dll's exit / destructors called. leaves me with problem of how to stop it happening - perhaps forcing order of dll "unload" - anyone have a clue how to do that?
thanks any way - at least it gives me something to work with
Jens
|
|
|
|
|
|
Thanks Sohail - an interesting article linked on your blog
seems to be exactly my problem...but I found the solution unclear.
Sounds like I need a "pre destruct" function to call in first dll, to set the smart pointers to null (as I tried, but failed to do during destruction), then call this function before 2nd calling dll starts its destruction. Only problem is, what if 1st dll destroys first, then calling it will also fail. Seems either way I might get an access violation unless I can control sequence of dll unload.
Hm, perhaps application need to call predestructor, before terminating - except then dll is destryed for other use (not an issue in my case, but not nice - althiugh I guess I am "only" clearing non-global smart pointers, so I guess that is ok...but ugly)
<br />
App >> Dll2 >> Dll1(with smartptrs)<br />
|______>Dll2.predestoy<br />
...........|___>Dll1.predestroy<br />
Any suggestions are welcome
Jens
(Sometimes I miss the old C "you allocate it, you deallocate it" days. Sure, we made mistakes, but atleast we knew what was happening.)
PS edited to get my code picture looking right, had to add "." as spaces were stripped - what kind of code view strips spaces and indentation anyway?
-- modified at 15:51 Thursday 5th January, 2006
|
|
|
|
|
Hey this is my simple soluction, can u try this and
tell me whether it is solved or not...
In the main termination of your application:-
you can do one of the following
CYourClass::ExitInstance()
{
HANDLE h1 = GetModuleHandle("dll1.dll")
HANDLE h2 = GetModuleHandle("dll2.dll")
Now you got wto handles you can free those libraries in
the order you specified as
FreeLibrary(h1);
FreeLibrary(h2);
or
FreeLibrary(h2);
FreeLibrary(h1);
}
mithun
|
|
|
|
|
That is a great idea, just what I was trying to do.
I can't believe it did not remember how to do it - I was considering writing my own callable exit functions in dlls to null the smart pointers so I would be independent of DLL unload order. I won't have a chance to try for a bit, but when I try I will post back.
Thanks Mithun
Jens
-- modified at 12:13 Friday 13th January, 2006
|
|
|
|
|
Hi ,
I have developed the com addin for outlook 2003 . I am creating the toolbar in all the folders. I am loading toolbar when we open the mail item. It's working fine loading the toolbar but when i receive the mail item with RichText format and INternationalisation option Set to Chinese Traditional Big5. When i open such mail item the toolbar doesnot loads. I am Getting problem adding the Control for editing the mail and Setting the font size. When i remove these controls the toolbar is loaded smoothly. I wam Attaching the code for your help in code snippet.
This code works but when you remove the comments for Edit This Mail and Font Size it does not wiork. I think when
the user receives the mail with RichText Format and INternation option set Chinese Traditional Big5 we dont get the
controls in standard toolbar itself , so that we cannot add those control so is there anyway to predict which type of mail is this or check if the mail is Ruch Text Edit or Internation Option Set to Chinese Traditional Big5.
// TODO: Add your implementation code here
CComQIPtr <outlook::_inspector> spInspector(OlInsp);
CComPtr <office::_commandbars> spCommandBars;
CComPtr <office::commandbar> spNewBar;
CComPtr <office::commandbar> spNewMenuBar;
CComPtr <office::commandbarcontrols> spBarControls;
CComPtr <office::commandbarcontrols> spMenuBarControls;
CComPtr <office::commandbarcontrols> spDropDownControls;
CComPtr <office::commandbarcontrols> spDropDownControls1;
CComPtr <office::commandbarcontrol> spCmdControl;
CComPtr <office::commandbarcontrol> control;
CComQIPtr <office::_commandbarbutton> spCmdButton(spCmdControl);
CComQIPtr <office::commandbarpopup> spCmdPopup(spCmdControl);
HRESULT hr;
spInspector->get_CommandBars(&spCommandBars);
spBars=spCommandBars;
hr=spCommandBars->get_Item(CComVariant(Name),&spNewBar);
if (SUCCEEDED(hr))
return hr;
IDispatch *TempItem;
CComPtr<outlook::_mailitem> CurrItem;
Outlook::OlObjectClass olmyClass;
spInspector->get_CurrentItem(&TempItem);
CurrItem=reinterpret_cast<outlook::_mailitem*>(TempItem);
hr=CurrItem->get_Class(&olmyClass);
char *str=new char[4];
itoa(olmyClass,str,5);
::MessageBox(NULL,str,"Outlook",MB_OK);
CComVariant vName(Name);
CComVariant vPos(1);
CComVariant vTemp(VARIANT_TRUE);
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
spNewBar=spCommandBars->Add(vName, vPos, vEmpty, vTemp);
spNewBar->Visible=true;
spBarControls = spNewBar->GetControls();
ATLASSERT(spBarControls);
//Declare Variant Types
CComVariant vToolBarType(1); //Simple Button
CComVariant vToolBarDropDown(10); //Drop Down Button
CComVariant vShow(VARIANT_TRUE); //True
CComVariant vType(Office::msoButtonIconAndCaption); //Style for Button
//Previous Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant(359) );
CComQIPtr <office::_commandbarbutton>spCmdPrevMail(control->Copy(CComVariant(spNewBar)));
spCmdPrevMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdPrevMail->Caption= "Previous Mail";
//Next Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant (360));
CComQIPtr < Office::_CommandBarButton>spCmdNextMail(control->Copy(CComVariant(spNewBar)));
spCmdNextMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdNextMail->PutFaceId(360);
spCmdNextMail->Caption="Next Mail";
//Edit This Mail
/* control=spCommandBars->FindControl(vEmpty,CComVariant (5604),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdEditMail(control->Copy(CComVariant(spNewBar)));
spCmdEditMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdEditMail->PutFaceId(31);
spCmdEditMail->Caption="Edit This Mail";
::MessageBox(NULL,"here 2","",0);
//Font Size
control=spCommandBars->FindControl(vEmpty,CComVariant (5571),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdFontSize(control->Copy(CComVariant(spNewBar)));
spCmdFontSize->PutStyle(Office::msoButtonIconAndCaption);
spCmdFontSize->Caption="Font Size";
::MessageBox(NULL,"here 3","",0);
*/
//Copy
control=spBarControls->Add(CComVariant(1),CComVariant(19));
CComQIPtr < Office::_CommandBarButton> spCmdCopy(control->Move(CComVariant(spNewBar)));
spCmdCopy->PutStyle(Office::msoButtonIconAndCaption);
spCmdCopy->Caption="Copy";
spButton1->put_Tag(L"InboxLv1");
SaveCloseInbox::DispEventAdvise((IDispatch*)spButton1);
*pNewBar=spNewBar;
return S_OK;
I look forward to your reply,
Regards
Ganesh
hi
|
|
|
|
|
I have a COM inproc dll and have written a mc file containing my own custom HResults. When my component throws the HRESULT, I am checking for its value in my MFC Client by use of FormatMessage.
The HR value returned matches with the message ID but the message string comes out to a garbage value.
Has anyone written custom HRs in component and displayed the message in the MFC client before? If yes, how does it work?
Thanks for the help!
-Mandira
|
|
|
|
|
Hi,
I am trying to use Windows Media Player library "WMSServerTypeLib.dll" as an interop. I created the "WMSServerLib.dll" type library and registered using regasm.
When I try to create the object,it throws the following com exception error:
COM object with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} is either not valid or not registered.
WMSServerClass Server = new WMSServerClass();
I am able to see all the Interfaces in the object viewer
rgds
Jaffar
-- modified at 6:22 Tuesday 27th December, 2005
|
|
|
|
|
When you create an interop Dll you do not register it with regasm. An interop Dll is not a COM Dll, it is a mapping between C# and the actual COM object. You may have replaced the media player COM object with your interop Dll.
|
|
|
|
|
Hi all,
i ahve downloaded a WMI application to get WMI data from maremote computer .
i have taken a win32 console application and included a source file an dto that source file i have included the code
#include "Windows.h"
#include "comdef.h"
//#include "Wbemidl.h"
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
int main(int argc, char **argv)
{
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
// Note: If you are using Windows 2000, you need to specify -
// the default authentication credentials for a user by using
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
// parameter of CoInitializeSecurity ------------------------
hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
cout << "Failed to create IWbemLocator object."
<< " Err code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
IWbemServices *pSvc = NULL;
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
if (FAILED(hres))
{
cout << "Could not connect. Error code = 0x"
<< hex << hres << endl;
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
if (FAILED(hres))
{
cout << "Could not set proxy blanket. Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_OperatingSystem"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
// Get the value of the Name property
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
wcout << " OS Name : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}
// Cleanup
// ========
pSvc->Release();
pLoc->Release();
pEnumerator->Release();
pclsObj->Release();
CoUninitialize();
return 0; // Program successfully completed.
}
but when iam compiling iam getting the following error
fatal error C1083: Cannot open include file: 'Wbemidl.h': No such file or directory
so can u please me regarding this
abhi
|
|
|
|
|
Hi
I gave developed the com addin for outlook 2003. I am attaching toolbar in inbox second level. If the username is in Chinese Traditional Charset then it doesn't work. I mean the toolbars does not get attached.
I have written code and on reveiewing i think something goes wrong here..
CComPtr<outlook::recipient>CurrUser;
BSTR username;
char* strName=new char[50];
mysession->get_CurrentUser(&CurrUser);
CurrUser->get_Name(&username);
strcpy(strName,"\nCreated By: ");
strName=strcat(strName,_com_util::ConvertBSTRToString(username));
strcpy(m_username,strName);
delete strName;
strName=0;
...
This is not unicode strings char* and if username is Chinese Traditional charset code is imncorrect.
this coment was given by one of my senior friend.
Looking forward for reply,
Cheers
Ganesh
hi
|
|
|
|
|
Hello,
I am trying to play video inside a panel.
The problem is that i can't get a window handle for the planel and here is the code that i am wriiting:
pWindow->put_Owner (this->panel1->Handle);
[Error C2664]: 'IVideoWindow::put_Owner' : cannot convert parameter 1 from 'System::IntPtr' to 'OAHWND'
How can i fix this problem. My end goal is just to play the file in the panel not in a pop up window!!
Thanks
|
|
|
|
|
Hi,
I have to build a dll which doesn't get loaded into the process space of the client. It has to own its process space. I figured out that Out-of-proc exe is suitable option for me. But now I am bit confused about win nt services and out of proc exe.
My question is:
are both of these types compatible with all Win versions? 9x, 2k and XP?
Whats the basic difference between out of proc exe and winnt server?
Are there any address mapping issues with winnt service exes? or any other issues involved with winnt services?
Thanks a ton in advance.
Misha
|
|
|
|
|
I have written a component code ,server code and client code using c#.all the three were built successfully.but when i run the client code it throws a remoting exception "requested service cannot be found"
the server code and the client code r on the same computer.
i am new to this!!!!!! SOS
santosh
|
|
|
|
|
Dear all,
I am using EVC4 to try a ATL COM program. Some source codes are as following. I got a first-chance exception problem. Can anyone help to tell me the reason? Can we test the .dll using some tools like the ActiveX Control Test Container?
ConnectionCom.cpp
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ConnectionCom.h"
#include "ConnectionCom_i.c"
#include "Add.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Add, CAdd)
END_OBJECT_MAP()
class CConnectionComApp : public CWinApp
{
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
};
CConnectionComApp theApp;
BOOL CConnectionComApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance);
return CWinApp::InitInstance();
}
int CConnectionComApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
_Module.UnregisterServer();
return S_OK;
}
ConnectionCom.idl:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(4B15EACE-A33D-4E53-B815-5486B457AEDF),
dual,
helpstring("IAdd Interface"),
pointer_default(unique)
]
interface IAdd : IDispatch
{
[id(1), helpstring("method Add")] HRESULT Add(int a, int b);
};
[
uuid(7D8286AC-AA29-48B1-A3A9-9394D54EBE22),
version(1.0),
helpstring("ConnectionCom 1.0 Type Library")
]
library CONNECTIONCOMLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(1B58E8FD-6D14-45BB-88F1-1DF5CBC05932),
helpstring("_IAddEvents Interface")
]
// dispinterface _IAddEvents
// interface _IAddEvents : IUnknown
interface _IAddEvents : IUnknown
{
[id(1), helpstring("method ExecutionOver")] HRESULT
ExecutionOver(int Result);
};
[
uuid(C0B7BD5D-B23E-4B9A-9DAE-C32B3CCEF193),
helpstring("Add Class")
]
coclass Add
{
[default] interface IAdd;
//[default, source] dispinterface _IAddEvents; take this line
//out and put the line below in
[default, source] interface _IAddEvents ;
};
};
Add.h:
#ifndef __ADD_H_
#define __ADD_H_
#include "resource.h" // main symbols
#include "ConnectionComCP.h"
/////////////////////////////////////////////////////////////////////////////
// CAdd
class ATL_NO_VTABLE CAdd :
public CComObjectRootEx<ccommultithreadmodel>,
public CComCoClass<cadd, &clsid_add="">,
public IConnectionPointContainerImpl<cadd>,
public IDispatchImpl<iadd, &iid_iadd,="" &libid_connectioncomlib="">,
public CProxy_IAddEvents< CAdd >
{
public:
CAdd()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_ADD)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CAdd)
COM_INTERFACE_ENTRY(IAdd)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CAdd)
CONNECTION_POINT_ENTRY(IID__IAddEvents)
END_CONNECTION_POINT_MAP()
// IAdd
public:
STDMETHOD(Add)(int a, int b);
};
#endif //__ADD_H_
Add.cpp
#include "stdafx.h"
#include "ConnectionCom.h"
#include "Add.h"
/////////////////////////////////////////////////////////////////////////////
// CAdd
STDMETHODIMP CAdd::Add(int a, int b)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
Sleep(1000);
Fire_ExecutionOver(a+b);
return S_OK;
}
When I call the Add method from the client program, I got the problem.
Please help!
Best Wishes,
HWB
|
|
|
|
|
What kind of exception was it? A first chance exception just means that the debugger is being notified before the application itself has a chance to handle the exception (the second chance) - It doesn't describe the exception itself.
Steve
|
|
|
|
|
I have an OCX Control, created with Visual C++ 6.0
I created another new OCX control, similar to the first one with very little changes. I registered the new one and it replaced the old one.
My problem is that I want both. Renaming the OCX and registering did not help me. How do i do this? Any help is highly appreciated.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|