How to Use 32-bit StampResource() Function in Windows NT 3.51Last reviewed: August 3, 1995Article ID: Q133699 |
The information in this article applies to:
SUMMARYThe 32-bit setup toolkit function, StampResource(), is used to write string table resource data into binary (executable) files. This function is useful for customizing installed files with installation-specific resource data, such as a user's name, company, and so on. This article discusses issues specific to using this function in the 32-bit Setup Toolkit for Windows NT version 3.51.
MORE INFORMATIONStampResource() is prototyped in the 32-bit Setup Toolkit as follows:
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:
REFERENCESFor more information on the other parameters of StampResource(), or how StampResource() works in general, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q92525 TITLE : Using the Setup Toolkit Function StampResource |
Additional reference words: 3.51
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |