I am trying to port VS2005 code to VS2017. Right now, I am getting a run-time error which says
HINSTANCE hInst = AfxFindResourceHandle(lpszResource, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszResource, RT_DIALOG);
if (hResource == NULL)
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Cannot find dialog template named '%Ts'.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Cannot find dialog template with IDD 0x%04X.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
here I am getting hResource
as NULL
.
I cross checked which ID is it corresponding to in my resource folder. I could see the dialog with the ID is registered in the .rc file and hence the autogenerated Resource.h does have that ID.
The issue is my .exe is using a static lib which has these resources. I read that I have to link the .res files in configuartion->Resources but the issue is I don't have any .res files in that folder. I have a .rc file which includes all the resources and the rest are .bmp files.
These Resource generated headers are also from 2005 version and I suspect that I need to generate a new resource.h file for the newer version of VS.
Also, everything in the code is getting the right values at run-time. It just can't find the resources. I am not experienced with resources so I am confused where ::FindResources
is trying to find the file and what type of file. If it's trying to find some .res file with the corresponding ID then the issue is just that I don't have those .res files.