CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Andrew Truckle Guest

    [RESOLVED] Using embeded resources

    If I insert a binary file as an embed resource in my program, how can I then access this resource and if it was a standard binary file (or the equivalent).

    I know I can use LoadResource/FindResource to retrieve a HGLOBAL handle, but how the hell do I use this to say, read one character, a string, x bytes of data?


  2. #2
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Using embeded resources

    You might be able to use the RT_RCDATA type which is for application-defined
    data. Try FindResource or FindResourceEx to get the handle and LoadResource
    to load it and obtain a pointer to it in memory. From there you will have to implement
    your own data extraction functions but those should not be too difficult as long as
    you know the size of the items you are extracting. Just advance a pointer by that
    amount every time you obtain an item and you will be aimed at the next item.
    Here's one that will extract any data type and will treat the data as an array of
    characters :

    BYTE * ExtractItem( BYTE *pdata, BYTE *pdest, size_t itemsize )
    {
    memcpy( pdest, pdata, itemsize ); // copy data to destination
    return pdata + itemsize; // aim at next item
    }



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured