How to get a string returned from a MFC ActiveX in VC++

C, C++, Visual C++, C++.Net Topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to get a string returned from a MFC ActiveX in VC++

Post by Saman » Fri Dec 02, 2011 2:21 am

Code: Select all

void CTestOCXCtrl::MyFunc(BSTR FAR* myBstr) 
{
	USES_CONVERSION;
	
	char* byestr =" byeeeee";
	char mystr[100];

	strcpy(mystr, OLE2A(*myBstr));

	strcat(mystr,byestr);

	SysReAllocString(myBstr, A2COLE(mystr));
	return;
}
Be sure to add #include <AtlBase.h> and #include <AtlConv.h> probably on stdafx.h precompiled header file.
Post Reply

Return to “C/C++ Programming”