One way to customize your project configuration files is to use string replacement with STR files. Technically, the STR files are for language localization, but that doesn’t exclude using them for customization. In fact, when you create a new project using Platform Builder for Windows CE 6.0, your project will contain a cebase.str for you to set your device name in.
STR files are plain text files stored in your FILES\INTLTRNS\<Local> folder. If you aren’t sure which folder you are using, open a build window and check the setting for LOCALE:
STR files contain #define statements similar to C/C++ macro definitions, but different. The syntax is:
#define <String to replace> “<String to insert>”
String to replace is a string that will be replaced in the configuration files.
String to insert is a string to insert into the configuration files. This must be in quotes. NOTE: The string to replace will be replaced with the quotes and everything on the line up to the carriage return.
The STR files are read in by makeimg using FindFirstFile() and FindNextFile() so the name of your STR file is important. If you want to replace defines in other files, then you need to name your file so it read in after the other file(s). For example, platform.str will be read in after common.str, but before wceshellfe.str.
To create an example, let’s create a file named ZProject.str. I want to override some of the strings in common.str and create a string for my customer’s company name to use in HKEY_LOCAL_MACHINE\Software. Here is my file:
// Paths for SHGetSpecialFolderPath
#define LOC_PATH_WINDOWS                     "\\Windows"
#define LOC_PATH_DESKTOP                        "\\Windows\\Desktop"
#define LOC_PATH_STARTUP                        "\\Windows\\StartUp"
#define LOC_PATH_RECENT                           "\\Windows\\Recent Documents"
#define LOC_PATH_PROGRAMS                  "\\Windows\\Program Files"
#define LOC_PATH_FAVORITES                    "\\Windows\\Favorites Files"
#define LOC_PATH_FONTS                             "\\Windows\\Fonts"
#define LOC_PATH_MYDOCUMENTS         "\\Documents"
#define LOC_PATH_PROGRAMFILES          "\\Program Files"
#define LOC_PATH_APPDATA                       "\\Application Data"
#define LOC_CUSTOMER_NAME                 "Company A"
Note that I copied the LOC_PATH defines from common.str and modified some of them, then added LOC_CUSTOMER_NAME.
In Common.reg and wceappsfe.dat files, the LOC_PATH variables are used:
; The path lookups for SHGetSpecialFolderPath
[HKEY_LOCAL_MACHINE\SYSTEM\Explorer\Shell Folders]
                "Application Data"=LOC_PATH_APPDATA
                "My Documents"=LOC_PATH_MYDOCUMENTS
                "Program Files"=LOC_PATH_PROGRAMFILES
Which after processing can be found in reginit.ini:
; The path lookups for SHGetSpecialFolderPath
[HKEY_LOCAL_MACHINE\SYSTEM\Explorer\Shell Folders]
                "Application Data"="\\Application Data"
                "Favorites"="\\Windows\\Favorites Files"
                "My Documents"="\\Documents"
                "Program Files"="\\Program Files"
                "Programs"="\\Windows\\Program Files"
                "Recent"="\\Windows\\Recent Documents"
Note that the strings were replace by the strings in ZProject.str instead of the strings in common.str. Looking at the makeimg output we can see why:
makeimg: Moving files from usasnap to release...
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\cebase.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\common.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\datasync.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\directx.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\ie.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\odo.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\shell.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\viewers.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\wceappsfe.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\wceshellfe.str
makeimg: Read string substitutions from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intltrns\0409\ZProject.str
makeimg: Copy files from C:\WINCE500\PBWorkspaces\AUTOMARKIA\RelDir\AUTOMARK_ARMV4I_Release\intlfile\0409\ to release directory.
You can use a different file name and see where it ends up in the makeimg output.
In my Project.reg, I added:
Which ends up as:
[HKEY_LOCAL_MACHINE\Software\"Company A"]
The same works for wceappsfe.dat:
Which ends up in InitObj.dat as:
root:-Directory("Program Files")
root:-Directory("My Documents")
So you can see that STR files can be used by you to make changes to both your configuration files as well as the Public configuration files.
Copyright © 2008 – Bruce Eitman
All Rights Reserved