RE: How to copy a dialog resource from an EXE to a DLL
As a followup to my problem we can put this one in the ground. The code will
work when copying resources from an EXE to anotherer EXE but for some reason
we cannot copy a resource from an EXE to a DLL.
Now, we can compile resources into a DLL...sooooo, why can't we put
resources into a DLL at runtime like we would an EXE?
That is just a rhetorical question.
The answer I want to give would be neither professional nor appropriate for
this forum. But it has to do with 20+ years of experience programming in a
Microsoft environment.
Thank you,
Jay
"Jay" wrote:
Does anyone know how to do this? I tried using the sample code in MSDN,
condensed below. Using the IDE I looked at "result" and it was true. All the
preceding variables appeared to have valid handles. But when I check the
second instance of "DlgStep1Resource", it is NULL.
Can anyone help me.
Thank you very much.
void CImportController::SetResource(UINT DlgResourceID)
{
HGLOBAL DlgStep1ResourceHandle;
HMODULE ParentModule;
HRSRC DlgStep1Resource;
HANDLE hdlUpdateResource;
LPVOID pTemplate;
ParentModule = ::LoadLibrary("ImportPrototype.exe");
DlgStep1Resource = FindResource(ParentModule,
MAKEINTRESOURCE(DlgResourceID), RT_DIALOG);
DlgStep1ResourceHandle = ::LoadResource(ParentModule, DlgStep1Resource);
pTemplate = (LPVOID) ::LockResource(DlgStep1ResourceHandle);
hdlUpdateResource = ::BeginUpdateResource("ImportWizardFrameworkD.DLL",
FALSE);
DWORD ressize = SizeofResource(ParentModule, DlgStep1Resource);
BOOL result = ::UpdateResource(hdlUpdateResource, // update resource
handle
MAKEINTRESOURCE(RT_DIALOG), // change dialog box
resource
MAKEINTRESOURCE(DlgResourceID), // dialog box name
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language
pTemplate, // ptr to resource info
ressize); // size of resource info.
result = ::EndUpdateResource(hdlUpdateResource, FALSE);
// See if the dialog really got copied
ParentModule = ::LoadLibrary("ImportWizardFrameworkD.DLL");
DlgStep1Resource = FindResource(ParentModule,
MAKEINTRESOURCE(DlgResourceID), RT_DIALOG);
}