Page 1 of 1

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

Posted: Fri Dec 02, 2011 2:21 am
by Saman

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.