Hello, i made a C Program that identify the n° of bytes of a determined resource.
Here is the code:
rc.rc(Resource file)
Code:
#include "rc.h"
DD DIALOGEX 6,5,167,49
CAPTION "Testando"
{
CONTROL "Digite alguma coisa:",label,"Static",0x50000000,50,3,66,20
CONTROL "",txt,"Edit",0x500100C0,4,14,160,13,0x00000200
CONTROL "Criar",btn,"Button",0x50010001,56,29,54,13
}
data RCDATA
{
"C:\\cs.exe"
}
rc.h(Header File)
Code:
#define DD 1
#define btn 2
#define data 3
#define txt 4
#define label 5
Main File
Code:
#include<windows.h>
#include "rc.h"
LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
DialogBox(hInstance,MAKEINTRESOURCE(DD),NULL,(DLGPROC)WinProc);
}
LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_COMMAND:
if(wParam==btn)
{
HRSRC hRes = FindResource(0, MAKEINTRESOURCE(DD), RT_RCDATA);
HGLOBAL hMem = LoadResource(0, hRes);
void *pMem = LockResource(hMem);
DWORD size = SizeofResource(0, hRes);
SetDlgItemInt(hwnd,txt,size,false);
}
break;
}
return 0;
}
Well the problem is that the program not return the number of bytes, its return 0
Someone knows the problem?
Thanks
Bye