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

  • 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?
1 Solution
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?
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.


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