Click here to Skip to main content
15,921,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: concept of uploading... Pin
_AnsHUMAN_ 26-Jun-07 21:50
_AnsHUMAN_ 26-Jun-07 21:50 
GeneralRe: concept of uploading... Pin
tasumisra26-Jun-07 22:04
tasumisra26-Jun-07 22:04 
AnswerRe: concept of uploading... Pin
Mark Salsbery27-Jun-07 6:07
Mark Salsbery27-Jun-07 6:07 
GeneralRe: concept of uploading... Pin
tasumisra29-Jun-07 6:12
tasumisra29-Jun-07 6:12 
GeneralRe: concept of uploading... Pin
Mark Salsbery2-Jul-07 13:44
Mark Salsbery2-Jul-07 13:44 
AnswerRe: concept of uploading... Pin
Moak29-Jun-07 1:26
Moak29-Jun-07 1:26 
QuestionHow to close a user created message box without effecting the parent window Pin
msr_codeproject26-Jun-07 20:41
msr_codeproject26-Jun-07 20:41 
AnswerRe: How to close a user created message box without effecting the parent window Pin
Jhony george26-Jun-07 21:43
Jhony george26-Jun-07 21:43 
GeneralRe: How to close a user created message box without effecting the parent window Pin
msr_codeproject26-Jun-07 23:29
msr_codeproject26-Jun-07 23:29 
AnswerRe: How to close a user created message box without effecting the parent window Pin
prasad_som27-Jun-07 1:31
prasad_som27-Jun-07 1:31 
GeneralRe: How to close a user created message box without effecting the parent window Pin
msr_codeproject27-Jun-07 2:05
msr_codeproject27-Jun-07 2:05 
QuestionHow to forward delare CArray class ? Pin
VCSharp00726-Jun-07 20:21
VCSharp00726-Jun-07 20:21 
AnswerRe: How to forward delare CArray class ? Pin
CPallini26-Jun-07 20:50
mveCPallini26-Jun-07 20:50 
AnswerRe: How to forward delare CArray class ? Pin
Nibu babu thomas26-Jun-07 21:00
Nibu babu thomas26-Jun-07 21:00 
GeneralRe: How to forward delare CArray class ? Pin
VCSharp00726-Jun-07 22:31
VCSharp00726-Jun-07 22:31 
GeneralRe: How to forward delare CArray class ? Pin
Nibu babu thomas26-Jun-07 22:39
Nibu babu thomas26-Jun-07 22:39 
AnswerRe: How to forward delare CArray class ? Pin
KarstenK26-Jun-07 21:28
mveKarstenK26-Jun-07 21:28 
QuestionEnumerating Installed Apps with MSI Pin
Akin Ocal26-Jun-07 20:13
Akin Ocal26-Jun-07 20:13 
QuestionBSTR in C++ Pin
Axonn Echysttas26-Jun-07 19:45
Axonn Echysttas26-Jun-07 19:45 
Hi everybody. I got a tiny question about a strange problem I'm having when I'm trying to receive a string from Visual Basic into C++. I got a VB string saying "Arial". But when I'm receiving it in C++, it becomes "Ail". Probably some wide characters versus normal characters problem, as i get 1 character and the next not, and then the next, I get. In order to make the conversion I'm using these two functions.

<br />
<br />
//Finds out the length of a BSTR.<br />
long GetLengthOfBSTR (BSTR Target)<br />
{<br />
	long iRet = 0; //Result to return.<br />
	long iCursor = 0; //Interator through the BSTR.<br />
	bool bForever = false; //To cycle forever.<br />
	<br />
	//If the string is NULL.<br />
	if (Target == NULL)<br />
		return(0); //Returning zero length.<br />
	while (!bForever) //Cycling forever.<br />
	{<br />
		unsigned int uiPiece = Target[iCursor]; //Piece by piece.<br />
		//Until reaching the null termination of the string.<br />
		if (uiPiece == 0)<br />
			return(iRet); //Returning the computed length.<br />
		else<br />
			iRet++; //Increasing the length.<br />
		iCursor++; //Increasing the BSTR iterator.<br />
	}<br />
	return -1; //Mostly to avoid warnings ::- ).<br />
}<br />
<br />
//Converts a BSTR to a Char. Needed when working with strings with Visual Basic.<br />
char *ConvertBSTRToChar (BSTR Target)<br />
{<br />
	char *sResult; //Result to return.<br />
	long iCounter; //Iterator.<br />
	long iLength; //Length of Target.<br />
	<br />
	iCounter = iLength = GetLengthOfBSTR(Target); //Initializing.<br />
	sResult = new char[iLength + 1]; //Creating a character big enough to hold the result.<br />
	strcpy(sResult, ""); //Initializing.<br />
	for (iCounter = 0; iCounter < iLength; iCounter++) //Going through the Target BSTR.<br />
	{<br />
		unsigned int uiPiece = Target[iCounter]; //Taking it piece by piece.<br />
		sResult[iCounter] = uiPiece; //Adding it in the final result.<br />
		sResult[iCounter + 1] = '\0'; //Adding null termination.<br />
	}<br />
	return sResult; //Returning computed char.<br />
}<br />


And then I do:

<br />
LPCSTR c;<br />
c = ConvertBSTRToChar(StuffFromVB);<br />
MessageBox(0, c, "Test", 0);<br />


SO? Anybody here to enlighten me a bit about this? : ). Thank you very much for your time here anyway!

-= E C H Y S T T A S =-
The Greater Mind Balance

Blending C++ with COM ^

AnswerRe: BSTR in C++ Pin
Nibu babu thomas26-Jun-07 20:10
Nibu babu thomas26-Jun-07 20:10 
GeneralRe: BSTR in C++ Pin
Axonn Echysttas26-Jun-07 20:52
Axonn Echysttas26-Jun-07 20:52 
GeneralRe: BSTR in C++ Pin
Nibu babu thomas26-Jun-07 21:06
Nibu babu thomas26-Jun-07 21:06 
AnswerRe: BSTR in C++ Pin
Arman S.26-Jun-07 20:16
Arman S.26-Jun-07 20:16 
GeneralRe: BSTR in C++ Pin
Axonn Echysttas26-Jun-07 20:48
Axonn Echysttas26-Jun-07 20:48 
GeneralRe: BSTR in C++ Pin
CPallini26-Jun-07 21:06
mveCPallini26-Jun-07 21:06 

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.