Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » [Resolved] char* with "\0" between each char (Char* returned from OLE VARIANT is weird)
[Resolved] char* with "\0" between each char [message #50876] Fri, 11 January 2019 13:56 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello there !

First of all, I wish you all a happy new year !
Today I'm trying to take control of Excel via OLE I did this code :
char* MyExcel::TestingNameOfSheet(){
	
	VARIANT AppResult={0};
	VARIANT AtmSheet={0};
	
	VariantInit(&AppResult);
	VariantInit(&AtmSheet);
	VariantClear(&lgVariant);
	
	lgVariant.vt = VT_I4;
	lgVariant.lVal = 2;	
	
	AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &AppResult,xlApp.pdispVal, L"Worksheets", 1, lgVariant);
	AutoWrap(DISPATCH_PROPERTYGET, &AtmSheet, AppResult.pdispVal, L"Name", 0);
	
	return AtmSheet.pcVal;
}

Somewhere else in my code I did this :
...
test = excel.TestingNameOfSheet();
	Cout() << "------------Begin-------------" << "\n";
		if(test !=0){
		do{
			Cout() << (int)*test << "\n";
		}while(++test);
	}
	Cout() << "\n------------Leave-------------" << "\n";
...

this code put into test the name of sheet2 from excel. in my case ("Feuil2").
problem is, when I read it with my "do while" I only get "F" because test is equal to "F\0e\0u\0i\0l\02\0\0\0\0\0 ...".
Can someone explain me why test looks like that ? is it normal ? Or did I make something like classic OLE error ?

Thanks in advance

Best Regard

[Updated on: Mon, 21 January 2019 14:51]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help needed to compile windows service example code
Next Topic: [Resolved] Exitcode : 3221225477
Goto Forum:
  


Current Time: Thu Mar 28 15:37:17 CET 2024

Total time taken to generate the page: 0.01425 seconds