Thank you, Joe, for giving it a shot. I followed your prescription, including
correcting the language IDs (should be LANG_ENGLISH, SUBLANG_ENGLISH_US).
The FreeLibrary is missing for two reasons: 1. It wasn't in the Microsoft
sample. Imagine that. 2. I'm prototyping, running the IDE 10 times a minute,
so don't care about memory at the moment. I put it in anyway just to dot all
my i's.
to first instance.
P.S. I agree it is a convoluted way to get a resource into a DLL (at
runtime) but that is what Microsoft tells me to do. For reasons why I need to
do this see my reply to the second person who posted a reply to my question.
"Joseph M. Newcomer" wrote:
Tyr LoadLibraryEx with the LOAD_LIBRARY_AS_DATAFILE option and see if you get a better
result.
This seems to be a convoluted way to get a resource into a DLL. Also, see below...
On Thu, 10 Jan 2008 08:23:04 -0800, Jay <Jay@discussions.microsoft.com> 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);
****
_T() around string constants.
****
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);
****
And where did you do the FreeLibrary?
****
// See if the dialog really got copied
ParentModule = ::LoadLibrary("ImportWizardFrameworkD.DLL");
DlgStep1Resource = FindResource(ParentModule,
MAKEINTRESOURCE(DlgResourceID), RT_DIALOG);
****
I see no "second instance" here; I do see a second assignment to the first instance. Also,
did you try to open the DLL using VS to see what its resources now are? Note that you are
using LANG_NEUTRAL, SUBLANG_NEUTRAL, but is that the language that is being used for
FindResource? You may be putting it out in one language and reading it with your default
language, so it isn't found.
joe
****
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm