I'm still having problems with loading resources, here is the most up to date code:
main.cpp:
Code:
#include <windows.h>
#include "Resource.h"
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int iCmdShow)
{
HMODULE hModule = GetModuleHandle(NULL);
DWORD err = 0;
HRSRC hrsrc = ::FindResource( NULL, MAKEINTRESOURCE(MYTXTFILE), TEXT("TEXT"));
err = ::GetLastError(); if(err) { TCHAR bug[256]; wsprintf(bug, TEXT("%d"), err); ::MessageBox(0, bug, "1", 0); }
HGLOBAL rsc = ::LoadResource( NULL, hrsrc );
err = ::GetLastError(); if(err) { TCHAR bug[256]; wsprintf(bug, TEXT("%d"), err); ::MessageBox(0, bug, "2", 0); }
LPVOID lock = ::LockResource( rsc );
err = ::GetLastError(); if(err) { TCHAR bug[256]; wsprintf(bug, TEXT("%d"), err); ::MessageBox(0, bug, "3", 0); }
DWORD size = ::SizeofResource( NULL, hrsrc );
err = ::GetLastError(); if(err) { TCHAR bug[256]; wsprintf(bug, TEXT("%d"), err); ::MessageBox(0, bug, "4", 0); }
MessageBox( HWND_DESKTOP, (const char*) &lock, "", MB_OK );
return 0;
}
resources.rc:
Code:
#include "Resource.h"
MYTXTFILE TEXT "mytextfile.txt"
Resource.h:
Code:
#ifndef RLOADER_RESOURCE_H
#define RLOADER_RESOURCE_H
#define MYTXTFILE 10001
#endif
And mytextfile.txt simply contains "ABC". The first GetLastError function used returns two, which according to msdn means "The system cannot find the file specified." I can't work out how to fix this though, maybe it's a problem with devcpp but I'm out of ideas. Do you (or anyone really) know how to get this program to work? Thanks.