Hey,
I have the following code.
I basically have to open a metafile which is stored as a resource. I have to pass it into the ReadMetaInt function as istream. This used to open the metafile from a physical file on teh hard drive. I want to be able to open them as resources and then pass them into that function.Code:#include <stdio.h> #include <iostream.h> #include "resource.h" short ReadMetaInt( istream& is, UINT& ints_read); int Metas[1] = {JVEST01C}; HRSRC reshandle; HMODULE hexe; HGLOBAL hglobal; int main() { printf("1st element: %d\n", Metas[0]); hexe = GetModuleHandle(NULL); reshandle = FindResource(hexe, MAKEINTRESOURCE(Metas[0]), "Metafile"); if (reshandle == NULL) printf("Did not find resource.\n"); else printf("reshandle: %d\n", reshandle); hglobal = LoadResource(hexe, reshandle); if (hglobal == NULL) printf("Did not load resource\n"); else printf("hglobal: %d\n", hglobal); //istream* metastream = (istream*) LockResource(hglobal); istream *metastream = (istream*) LockResource(hglobal); if (metastream == NULL) printf("could not lock resource\n"); UINT ints_read = 0; int blah = ReadMetaInt(*metastream, ints_read); cout << blah; system("PAUSE"); return 100; } // --------------------------------------------------------------------------------------------- // Read an integer from metafile. short ReadMetaInt( istream& is, UINT& ints_read ) { unsigned char c1, c2; is.get( c1 ); is.get( c2 ); ints_read++; return( c1 + ( c2 << 8 ) ); } // ReadMetaInt
Right now, I get errors on the is.get(c1) line.




Reply With Quote