Click here to Skip to main content
15,880,427 members
Home / Discussions / COM
   

COM

 
AnswerRe: basic problem about atl Pin
Michael Dunn29-Aug-08 13:32
sitebuilderMichael Dunn29-Aug-08 13:32 
QuestionHow to call Com dll from VC++ .NET 2005? Pin
amalhotr26-Aug-08 7:39
amalhotr26-Aug-08 7:39 
AnswerRe: How to call Com dll from VC++ .NET 2005? Pin
Michael Dunn29-Aug-08 13:34
sitebuilderMichael Dunn29-Aug-08 13:34 
QuestionRemove All referance of OCX file from PC Pin
ASysSolvers26-Aug-08 6:17
ASysSolvers26-Aug-08 6:17 
AnswerRe: Remove All referance of OCX file from PC Pin
Ju@ncho11-Sep-08 2:51
Ju@ncho11-Sep-08 2:51 
QuestionHow to Get the 'fvalue' from an html option button Pin
Member 379724125-Aug-08 12:52
Member 379724125-Aug-08 12:52 
Question...Hiding folders from Explorer Pin
Attilah25-Aug-08 3:39
Attilah25-Aug-08 3:39 
QuestionWhy does it work, when it pass CString to COM interface? Pin
emailforjan24-Aug-08 20:58
emailforjan24-Aug-08 20:58 
I am new, the c++ com dll component is being used "in process of the c++ exe", we work in VS2005/VC8.
I come across code similar to below. It does seem to give the expected result/value.
I am wondering how or why it can use CString instead of BSTR? What conditon will this snippets of code work? And where and when will it fail? Thank you.
inside declareinterface.h
...
static const GUID IID_IArmProperties = 
{ 0x1b8eb07c, 0xcb4b, 0x4118, { 0xbd, 0x61, 0x54, 0xb8, 0x77, 0x30, 0xb8, 0x55 } };

DECLARE_INTERFACE_(IArmProperties, IUnknown)
{
...
	STDMETHOD(DoSomething)(THIS_ CString csComment, THIS_ double *pdRetDbl, THIS_ MISCPARAM* mmpParam) PURE;
};

inside implement.h
#include "declareinterface.h"
...
class ATL_NO_VTABLE CArmPropertiesImp:
	public IArmProperties
{
public:
	CArmPropertiesImp(void);
	virtual ~CArmPropertiesImp(void);

	BEGIN_COM_MAP(CArmPropertiesImp)
		COM_INTERFACE_ENTRY(IArmProperties)
	END_COM_MAP()
...
	STDMETHOD(DoSomething)(CString csComment,double *pdRetDbl,MISCPARAM* mmpParam);
};

where:
typedef struct _MISCPARAM 
{
	double dObject; 
	LPCWSTR lpszObject;	
	long* plRes;
} MISCPARAM;			


inside implement.cpp
...
STDMETHODIMP CArmPropertiesImp::DoSomething(CString csComment,double *pdRetDbl,MISCPARAM* mmpParam)
{
	m_memberdouble+=mmpParam->dObject;
	//remember like in c, csComment is copied and passed by value to here 
	m_membercstring+=csComment;
	if(m_membercstring.IsEmpty())
		*pdRetDbl=m_memberdouble+0.5;
	else
		*pdRetDbl=m_memberdouble+1.5;

	return S_OK;
}

inside caller.cpp
...
	MISCPARAM locparam={0};
	locparam.dObject=1;

	CString cslocalComment="Test";
	double localdouble=0;

	IArmProperties *piArm=NULL;
	if(m_pIMaster->QueryInterface(IID_IArmProperties,(LPVOID*)&piArm)==S_OK)
		if(piAlarm)
		{
			piArm->DoSomething(cslocalComments,&localdouble,&locparam);
		}

	if(localdouble==0)
		DoTheFunction();
	else if(localdouble<0)
		DoOtherFunction();
	else
		DoSomeOtherFunction();
...

AnswerRe: Why does it work, when it pass CString to COM interface? Pin
Roger Stoltz24-Aug-08 21:23
Roger Stoltz24-Aug-08 21:23 
Questionintercepting COM method calls .. Pin
Attilah22-Aug-08 19:50
Attilah22-Aug-08 19:50 
AnswerRe: intercepting COM method calls .. Pin
__DanC__19-Nov-08 3:48
__DanC__19-Nov-08 3:48 
QuestionProblem in Calling COM function in Customize Wizard code Pin
am 200921-Aug-08 2:08
am 200921-Aug-08 2:08 
QuestionA COM Interop Question Pin
Xiaoming Qian20-Aug-08 21:17
Xiaoming Qian20-Aug-08 21:17 
AnswerRe: A COM Interop Question Pin
User 21559720-Aug-08 23:50
User 21559720-Aug-08 23:50 
Questionget_LastLogoff() fails with Unknown error Pin
JoeSchmoe00719-Aug-08 6:51
JoeSchmoe00719-Aug-08 6:51 
AnswerRe: get_LastLogoff() fails with Unknown error Pin
Nibu babu thomas19-Aug-08 19:25
Nibu babu thomas19-Aug-08 19:25 
GeneralRe: get_LastLogoff() fails with Unknown error Pin
JoeSchmoe00720-Aug-08 4:52
JoeSchmoe00720-Aug-08 4:52 
GeneralRe: get_LastLogoff() fails with Unknown error Pin
Nibu babu thomas21-Aug-08 1:48
Nibu babu thomas21-Aug-08 1:48 
GeneralRe: get_LastLogoff() fails with Unknown error Pin
JoeSchmoe00721-Aug-08 4:35
JoeSchmoe00721-Aug-08 4:35 
QuestionHow to execute exe file in ATL COM Pin
am 200919-Aug-08 1:45
am 200919-Aug-08 1:45 
AnswerRe: How to execute exe file in ATL COM Pin
CPallini19-Aug-08 2:03
mveCPallini19-Aug-08 2:03 
AnswerRe: How to execute exe file in ATL COM Pin
sivagnaesh22-Aug-08 2:12
sivagnaesh22-Aug-08 2:12 
AnswerRe: How to execute exe file in ATL COM Pin
Michael Dunn29-Aug-08 13:37
sitebuilderMichael Dunn29-Aug-08 13:37 
QuestionAccessViolationException on Vista if not run in debugger?! [modified] Pin
mav.northwind18-Aug-08 8:31
mav.northwind18-Aug-08 8:31 
AnswerRe: AccessViolationException on Vista if not run in debugger?! Pin
User 21559718-Aug-08 18:38
User 21559718-Aug-08 18:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.