Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

ifstream from resource

Need to get ifstream from resource.
I have this:

int LoadResource (UINT res, char * szres)
{
  ......
  HINSTANCE hInst = AfxGetResourceHandle();
  HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(res), szres);
  BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);
  ......
}

How do I get ifstream from this?
0
jd9288
Asked:
jd9288
1 Solution
 
jkrCommented:
Without writing your own 'ifstream' implementation, the only way would be to save the bytes to a file and open that again, which for sure is cumbersome. Would 'CreateStreamOnHGlobal()' help?
0
 
jd9288Author Commented:
jkr, I figured it out.
I needed to load animated GIF file from resource, and I had the code
how to load it from disk (WINIMAGE.CPP by Juan Soulie), so I just used memcpy on the byte array to manually
do what the ifstream does.

I wanted to know if there was an easy way out, and you answered that.

Thanks.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now