Click here to Skip to main content
15,923,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalsize of file Pin
smarty128-Apr-05 8:26
smarty128-Apr-05 8:26 
GeneralRe: size of file Pin
David Crow8-Apr-05 8:56
David Crow8-Apr-05 8:56 
GeneralRe: size of file Pin
smarty129-Apr-05 7:06
smarty129-Apr-05 7:06 
GeneralRe: size of file Pin
Alexander M.,9-Apr-05 7:49
Alexander M.,9-Apr-05 7:49 
GeneralRe: size of file Pin
David Crow9-Apr-05 12:11
David Crow9-Apr-05 12:11 
GeneralBinary Resource Data Pin
#realJSOP8-Apr-05 5:47
professional#realJSOP8-Apr-05 5:47 
GeneralRe: Binary Resource Data Pin
David Crow8-Apr-05 6:07
David Crow8-Apr-05 6:07 
GeneralRe: Binary Resource Data Pin
#realJSOP8-Apr-05 6:24
professional#realJSOP8-Apr-05 6:24 
Found the following on CodeGuru. I adapted it to my needs and all is well. Smile | :)


<br />
For each file you want to include, add a line to resource.h as follows:<br />
<br />
  #define IDR_MYFILE 103<br />
<br />
Remember to give each file a unique resource ID.<br />
<br />
Close all resource files and open your .rc file as "text." Add the line<br />
<br />
  IDR_MYFILE RCDATA DISCARDABLE "res\\myfile.ext"<br />
<br />
A good place to add this line is immediately after the line which defines the IDR_MAINFRAME icon. If you haven't placed "myfile.ext" in your "res" subdirectory, adjust the path accordingly. Save the .rc file. Close it and open ResourceView. You should see something like this:<br />
<br />
There are more convenient ways of inserting a custom data resource, but they either embed the file as raw hex data in the .rc file, inflating it to several times the size of the included file, or neglect to define the resource ID in resource.h so that ResourceView shows the ID in inverted commas.<br />
<br />
To turn a resource back into a file, load it into memory using LoadResource(). This returns a BYTE pointer that CFile can use to write that file to disc.<br />
<br />
// Load the resource and save its total size.<br />
HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_MYFILE),RT_RCDATA); <br />
DWORD dwSize = SizeofResource(NULL , hRes);<br />
HGLOBAL MemoryHandle = LoadResource(NULL, hRes);<br />
if(MemoryHandle != NULL)<br />
{<br />
  // LockResource returns a BYTE pointer to the raw data in<br />
  // the resource<br />
  BYTE *MemPtr = (BYTE *)LockResource(MemoryHandle);<br />
  CFile file("C:\_my_path_to_file\myfile.ext", CFile::modeCreate | CFile::modeWrite);<br />
  file.Write(MemoryHandle,dwSize);<br />
}<br />
FreeResource((HANDLE)hRes);<br />
<br />


------- sig starts

"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt

"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
GeneralRe: Binary Resource Data Pin
Ravi Bhavnani8-Apr-05 7:52
professionalRavi Bhavnani8-Apr-05 7:52 
GeneralRe: Binary Resource Data Pin
David Crow8-Apr-05 7:54
David Crow8-Apr-05 7:54 
GeneralRe: Binary Resource Data Pin
Ravi Bhavnani8-Apr-05 7:59
professionalRavi Bhavnani8-Apr-05 7:59 
GeneralSplitter Window get/pass information Pin
poiut8-Apr-05 5:33
poiut8-Apr-05 5:33 
GeneralRe: Splitter Window get/pass information Pin
RobJones8-Apr-05 18:27
RobJones8-Apr-05 18:27 
QuestionHow to use non .NET DLLs in .NET environment? Pin
Khang Nguyen8-Apr-05 5:30
Khang Nguyen8-Apr-05 5:30 
AnswerRe: How to use non .NET DLLs in .NET environment? Pin
Chris Losinger8-Apr-05 7:01
professionalChris Losinger8-Apr-05 7:01 
GeneralRe: How to use non .NET DLLs in .NET environment? Pin
Khang Nguyen8-Apr-05 8:00
Khang Nguyen8-Apr-05 8:00 
Generalcreate Network Setup Wizard Pin
javad_20058-Apr-05 5:17
javad_20058-Apr-05 5:17 
GeneralProblem with UDP packets Pin
Virendra Sharma8-Apr-05 5:17
Virendra Sharma8-Apr-05 5:17 
GeneralRe: Problem with UDP packets Pin
Indivara8-Apr-05 19:23
professionalIndivara8-Apr-05 19:23 
GeneralCPropertySheet problem Pin
Bob Stanneveld8-Apr-05 2:04
Bob Stanneveld8-Apr-05 2:04 
GeneralRe: CPropertySheet problem Pin
toxcct8-Apr-05 2:24
toxcct8-Apr-05 2:24 
GeneralRe: CPropertySheet problem Pin
David Crow8-Apr-05 4:49
David Crow8-Apr-05 4:49 
GeneralRe: CPropertySheet problem Pin
Bob Stanneveld10-Apr-05 21:00
Bob Stanneveld10-Apr-05 21:00 
GeneralRe: CPropertySheet problem Pin
Michael Dunn8-Apr-05 6:44
sitebuilderMichael Dunn8-Apr-05 6:44 
GeneralRe: CPropertySheet problem Pin
Bob Stanneveld10-Apr-05 21:01
Bob Stanneveld10-Apr-05 21:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.