Hi, I am trying to understand what is going on with my NameId in my Resource.rc file.
Here is my main source, .h, and .rc.
I found the base code in a forum and modified it slightly.
=========
.rc file contents
=========
#include "Resource.h"
ID_Ed1 RCDATA "C:\\WINDOWS\\NOTEPAD.EXE"
============================================
=========
Resource.h file contents
=========
#define ID_Ed1 1
============================================
=========
main source file
=========
#include <windows.h>
#include <stdio.h>
#include "Resource.h"
int main(int argC, char *argV[])
{
// Get pointer and size to resource
HRSRC hRes = FindResource(0, MAKEINTRESOURCE(ID_Ed1), RT_RCDATA);
HGLOBAL hMem = LoadResource(0, hRes);
void *pMem = LockResource(hMem);
DWORD size = SizeofResource(0, hRes);
// Write it to a file
char *fname = "test.exe";
FILE *f = fopen(fname, "wb");
fwrite(pMem, size, ID_Ed1, f);
fclose(f);
// Execute it
system(fname);
return 0;
}
============================================
Now Why MUST I define [#define ID_Ed1 1] ID_Ed1 as the unsigned integer 1.
Though another number will allow me to build, the build main.exe will crash on my computer when I run it.
Use the number 1 and no problem.
I would really like to know why !!
What if I were trying to embed more than one binary as a custom resource (of type RT_RCDATA)?
I have read myself silly at MSDN, I really cannot find a whole lot of info/examples on using the RT_RCDATA type.
Help !!!
Tx, Ed