Sign in to follow this  

Resource DLL problem

This topic is 2124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently trying to add strings to an empty dll using the BeginUpdateResource, UpdateResource & EndUpdateResource without any luck. I've been hunting the web for several hours but all of the examples simply change an existing resource string, which is not what I need to do.

Using:
VC 2005 SP1
Win 7/Vista
C++ with MFC

[code]
HANDLE hdll;
DWORD dsz;
BOOL rv;
size_t osz,csz,nsz;
wchar_t *data;
CString d1,d2,tmp;
// set up data to test with
tmp="Test data.";
osz=(size_t)tmp.GetLength()+1;
csz=0;
nsz=osz*2;
data = new wchar_t [nsz];
mbstowcs_s(&csz,data,osz,tmp,_TRUNCATE);
dsz=sizeof(data);
// copy and paste blank.dll
d1=WorkFldr+"Blank.dll";
d2=WorkFldr+"Generated.dll";
DBFIO.CopyFiles(d1,d2); // make copy of empty dll
// update resource entry
hdll=BeginUpdateResource(d2,FALSE);
if(hdll==NULL) {
AfxMessageBox("BeginUpdateResource failed");
goto ex;
}
rv=UpdateResource(hdll,
RT_STRING,
MAKEINTRESOURCE(2),
MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),
&data,
dsz);
if(rv==FALSE) {
AfxMessageBox("UpdateResource failed");
goto ex;
}
rv=EndUpdateResource(hdll,FALSE);
if(rv==FALSE) {
AfxMessageBox("EndUpdateResource failed");
goto ex;
}
ex:
delete [] data;
[/code]

Any c++ example code would be appreciated. I does create a "101" resource but not a "2" resource. The "101" is blank though.

Share this post


Link to post
Share on other sites

This topic is 2124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this