Article ID: 133699
Article Last Modified on 1/12/2000
VOID StampResource(LPSTR szSect, LPSTR szKey, LPSTR szDst,
int wResType, int wResId, LPSTR szData, int cbData);
Notice that the szData argument is prototyped as LPSTR. All string resource
data in Windows NT must be stored in UNICODE(tm) form. Therefore, because
StampResource() is writing directly into a binary file, you must convert
the string data for StampResource() into wide-character format. That means
you must make your szData string parameter type LPWSTR. The following
example shows how this can be done:
INT size;
TCHAR buf[80], szName[40],szCompany[20],szProductID[20];
LPWSTR wUnicodeString;
lstrcpy(szName,"Bob Smith");
lstrcpy(szCompany,"Microsoft");
lstrcpy(szProductID,"123-45-6789");
wsprintf(buf,"%c%s%c%s%c%s",lstrlen(szName),szName,lstrlen(szCompany),
szCompany,lstrlen(szProductID),szProductID);
size=MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,buf,-1,NULL,0);
wUnicodeString=(LPWSTR)GlobalAlloc(GMEM_FIXED,sizeof(WCHAR)*size);
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,buf,-1,wUnicodeString,size);
StampResource("Extra Files","Config","d:\\setup32\\stamp\\disks\\disk1",
6,0x451,(LPSTR)wUnicodeString,sizeof(WCHAR)*size);
GlobalFree((HGLOBAL)wUnicodeString);
In this example, the code performs these steps:
92525 Using the Setup Toolkit Function StampResource
Additional query words: 3.51
Keywords: KB133699