Solved

How define and update this string buffer

Posted on 2009-04-03
2
240 Views
Last Modified: 2013-12-14
Hi All,
I've created a string buffer in VB and then call a c++ MFC dll with an external function as follows. I pass the buffer through by reference. Then...
What I'm not sure about is how declare it as a parameter to the function and populate it with a value from a CString variable.

The code below doesn't work but hopefully gives you an idea of where I'm heading. It's kind of like a API. Also the return value must non-unicode.

Any suggestions will be greatly appreciated.
int __declspec(dllexport) __stdcall ReadXML(CString &MtBuffer, int length, BSTR xmlFilePath, BSTR xmlNode)

{

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

 

	CString str_xmlFilePath = BSTR2CString(xmlFilePath);

	CString str_xmlNode = BSTR2CString(xmlNode);

	

	CString	m_xml_value;

	m_xml_value = _T("");

	std::string _label;

	

	ParamIO inXml;

	inXml.readFile(str_xmlFilePath);

	inXml.read(str_xmlNode, _label, std::string(""));

	m_xml_value = _label.c_str();

	

	MtBuffer = m_xml_value;

	return 0;

}

Open in new window

0
Comment
Question by:ill_comms
2 Comments
 
LVL 19

Accepted Solution

by:
alb66 earned 125 total points
ID: 24057765
Give alook at
"How to pass arrays and strings between Visual Basic and C functions or between Visual Basic and C++ functions by using Visual Basic 6.0"
http://support.microsoft.com/?scid=kb%3Ben-us%3B205277&x=19&y=10
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now