|
From: JoeC on 31 Jul 2008 20:48 On Jul 4, 5:55 pm, Grzegorz Wróbel </dev/n...(a)localhost.localdomain> wrote: > JoeC wrote: > > > I am trying to work with the code I don't have good resources on how > > to do what I am trying to do. so p points to the data, how do I copy > > the data in p to my two variables > > int end (used to count the number of data elements and > > BYTE the data elements that go into a vector. > > However you like. You can use memcpy, you can cast void pointer p to > pointer of any type you wish and and then either use index operator with > it or dereference it. What's the problem? You don't know how to use > pointers? > > -- > Grzegorz Wróbel > 677265676F727940346E6575726F6E732E636F6D So far I have this: graphic::graphic(UINT uiResID, HINSTANCE hinstance){ size = 32; bitData.clear(); int * p = NULL; BYTE * d = NULL; static HGLOBAL hglob; HRSRC hRes = FindResource(hinstance,MAKEINTRESOURCE(uiResID),TEXT("BINARY")); if(hRes){ hglob = LoadResource(hinstance,hRes); p = (int*) LockResource(hglob); int end = *p; d = (BYTE*) LockResource(hglob); for(int lp = 0; lp != end; lp++){ BYTE data = ++*d; bitData.push_back(data); MessageBox(NULL, "Ping", "INFO!", MB_OK); } } set(); create(); } I will take into account what you suggest when I have time.
From: JoeC on 31 Jul 2008 23:42 On Jul 4, 5:55 pm, Grzegorz Wróbel </dev/n...(a)localhost.localdomain> wrote: > JoeC wrote: > > > I am trying to work with the code I don't have good resources on how > > to do what I am trying to do. so p points to the data, how do I copy > > the data in p to my two variables > > int end (used to count the number of data elements and > > BYTE the data elements that go into a vector. > > However you like. You can use memcpy, you can cast void pointer p to > pointer of any type you wish and and then either use index operator with > it or dereference it. What's the problem? You don't know how to use > pointers? > > -- > Grzegorz Wróbel > 677265676F727940346E6575726F6E732E636F6D Thanks for the tip. It seems like my program is reading my resources and I am working the bugs out of this part. I did take your suggestion of using memcpy and it compiles and runs. I still have some questions about getting all of this to work. It has to do with having two typs of data that p points to int and increasing p++ to point to the next bit of data. p++ does not work. So far I made some changes and this is what I now have: graphic::graphic(UINT uiResID, HINSTANCE hinstance){ size = 32; bitData.clear(); void * p = NULL; int end; BYTE data; static HGLOBAL hglob; HRSRC hRes = FindResource(hinstance,MAKEINTRESOURCE(uiResID),TEXT("BINARY")); if(hRes){ hglob = LoadResource(hinstance,hRes); p = LockResource(hglob); memcpy((int*) &end, p, sizeof(int)); for(int lp = 0; lp != end; lp++){ bitData.push_back(0); } for(int lp = 0; lp != end; lp++){ memcpy((BYTE*) &bitData[lp], p, sizeof(BYTE)); } } set(); create(); }
First
|
Prev
|
Pages: 1 2 Prev: Basic question about resources/ Next: Time measurement problem during task switching |