Hello, first off I hope I'm delivering the topic properly.
In short I'm having problems using a function that I think is from the Windows layer, called StgOpenStorage1. I'm trying to use it to read a file but it's giving me an error. Upon investigating the value of the HRESULT2 it turns out to be a FileAlreadyExists2 error, which confuses me since I thought this is a read operation.
I'll append only the code relevant to the problem, about 10-15 lines. There's also some reference links in the bottom that might be of your interest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
iretVal = XLVersionFromFile("C:\\JACK.xlsx");
int XLVersionFromFile(char *filename)
int i = mbstowcs(wcFilename, filename, strlen(filename));
wcFilename[i] = 0;
hr = ::StgOpenStorage(wcFilename, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &pStorage);
printf("\n\nError number 0x%x\n", hr);
- I'm using VS2010, had to do some code tweaks for that.
- I should note that I know other languages, but not C++. My apologizes for trying to use something that I did not learn, but it was the only option for my problem, and it didn't sound feasible to go deep into the language whereas all what I needed from it was only one seemingly simple module.
The example says that it determines version of .xls files whereas you are trying to determine version of .xlsx file. These two formats are very different, and I think this is the reason why your code doesn't work.
I've never seen an user do such a perfect first post.
Also your C++ "skills" are pretty good, looking at the syntax, tabbing, indentation...
It really looks like you could easily enter the C++ world.
On the topic:
You should use zlib to de-compress the xlsx, and get the right file to work with.
Let me enhance:
XSLX files are ZIP files.
Rename one, and try to see if you are able to work with one of the internal files.
Rename one, see if you are able to work with one of the internal files.
There's no need to rename the file to .zip; the file can be opened (with the appropriate zip library) whatever its extension. (Unless you want to make the file click-able in Explorer, of course.)[/quote]
That's what I meant, yes, even if I personally use the "Open With..." function.