INF Tasks


Index


Creating Folders and Links in Folders

Creating a folder in the Programs Folder or creating links in a folder is done by the shell after a component is installed.  It looks in the SETUP.INI file for a [progman.groups] section and then parses it to create folders and links in those folders.

If you are installing a component that will require a folder or links in the Programs Folder, create an UpdateInis section that will create the proper entries in SETUP.INI. SETUP.INI follows the following syntax to create folders and links.  Note that folders are relative to the Start Menu.


[progman.groups]
folder_1=Folder_1_Name
folder_2=Folder_2_Name:
folder_n=Folder_n_Name
[folder_1]
Link-Name, EXE-name, Icon-file-name, Icon-index, profile, start in folder
If the profile field is left NULL, the link will always be added to the folder.

NOTE: If EXE-name is NULL item will be deleted from the group if it exists there.
NOTE: If a Folder or Link has a space in it's description, you will need to use a double-quote to get this to show up in setup.ini. See examples below.

Example:Games

[Optional Components]
games
[games]
OptionDesc=%GAMES_DESC%
CopyFiles=wingames.files
UpdateInis=wingames.links
[wingames.files]
cards.dll
freecell.exe
freecell.hlp
mshearts.exe
mshearts.hlp
sol.exe
sol.hlp
winmine.exe
winmine.hlp
[wingames.links]

setup.ini,progman.groups,,"gamesfolder=%GAMES_DESC%" ;creates folder
setup.ini,gamesfolder,,"""Solitaire Game"",SOL.EXE,,," ;creates link
setup.ini,gamesfolder,,"Minesweeper,WINMINE.EXE,,," ;creates link
setup.ini,gamesfolder,,""Hearts Card Game"",MSHEARTS.EXE,,,";creates link
setup.ini,gamesfolder,,"FreeCell,FREECELL.EXE,,,C:\Windows" ;creates link

Result:entry will for "Games" will appear in the "Optional Components Dialog" in Setup, and if selected, a "Games" folder in the Programs Folder will be created with links to Solitaire, Minesweeper, Hearts and FreeCell:

Index


Creating and Deleting Long File Names

The setup engine in Windows 95/98/ME is a 16-bit DLL (since Windows 95/98/ME Setup it must run under Windows 3.x).  Because of this, the engine can only copy files with 8.3 filenames. In order to create and delete long file names, the setup engine runs a 32-bit application when it exits that will rename and 8.3 short filenames to long file names, and delete files with long file names.  The 32-bit application gets its instructions from pre­defined keys in the registry. The root branch of the registry for rename operations is the following:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RenameFiles

The root branch of the registry for delete operations is the following:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DeleteFiles

Each group of rename and delete operations are added to a subkey under each branch. Each group of operations is limited to renaming or deleting files in a single subdirectory. A minimum of two entries must be made in each subkey to affect a rename or delete: first, the directory path for the files to be renamed or deleted; second, the actual rename or delete operation.
The first key in each group of operations is the directory entry. Each entry for a rename operation in the related directory is an entry of the form "old_short_name"="new_long_name,[attrib_flag]".
The optional attrib_flag is used to set file attributes during the rename operation. The flag is composed of the following values.

1READONLY
2HIDDEN
4SYSTEM

To set multiple attributes on a file or folder, the flags are added together, i.e. to set the READONLY and HIDDEN attributes, attrib_flag would be 3
The following example is an AddReg section that sets the SYSTEM and HIDDEN attributes on the \Windows\System\Foo directory:

HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,,,%11%
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,FOO,,"FOO,6"

Note: you should use all CAPS to ensure that the name stays a short file name.
Each entry for a delete operation in the related directory is an entry of the form "arbitrary_key_name"="long_name_to_delete".
The following example is an AddReg section that will cause the Oldname.txt to be renamed to New Long Name.txt in the C:\Samples directory, and myreadme.txt to be renamed to My Application Readme.txt in the Windows directory:

[MyAppShort2Long]
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Samples,,,C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Samples,oldname.txt,,"New Long Name.txt"
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,,,%25%

HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,myreadme.txt,,"My App Readme.txt"

The following example is an AddReg section that will cause New Long Name.txt to be deleted from the C:\Samples directory, and My Application Readme.txt to be deleted from the Windows directory:

[MyAppDelLong]
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Samples,,,C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Samples,oldname.txt,,"New Long Name.txt"
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Win,,,%25%

HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Win,myreadme.txt,,"My App Readme.txt"

After these renames and deletes have been processed, the entries are removed from the registry.
Note: during the rename operation, the destination file is deleted before performing the rename. If the same rename operation is queued twice, it could result in a loss of the file. For example, suppose there is a bitmap that needs to be renamed, from Picture.bmp to "Really Cool 3D Picture.bmp." The second time such a rename operation is performed, "Really Cool 3D Picture.bmp" already exists, so it is deleted before performing the rename opreation. The exception to this rule is when the existing destination filename is a directory.

Index


Setting Attributes on Files and Folders

To set the attributes on a file or folder, you use the same convention to create long file names, using an optional flag.
See the Creating and Deleting Long File Names Section for details.

Index


Copying files to the Program Files folder


Since all of the copies done by the Windows 95/98/ME setup engine are done as 16-bit operations, only 8.3 short filenames can be used. To access the Program Files folder, you will need to use the 8.3 equivalent, "24,PROGRA`1", in the [DestinationDirs] section (LDID 24 is the Root of drive containing the Windows directory) .Similarly, the short file name equivalent must be used to access any folders with long file names that are below the Program Files Directory.
The example below copies three files to the Program Files\Accessories folder, and creates links to one of the files:

[WordPadInstall]
CopyFiles=WordPadCopyFiles
UpdateInis=WordPadInis
[DestinationDirs]

WordPadCopyFiles=24,%PROGRAMF%\%ACCESSOR%
[WordPadCopyFiles]

mswd6_32.wpc
wordpad.exe
write32.wpc
[WordPadInis]

setup.ini,progman.groups,,"group4=%APPS_DESC%" ;creates Accessories folder (if not already there)
setup.ini,group4,,"""%WORDPAD_LINK%"", ""%24%\%PROGRAMF%\%ACCESSOR%\WORDPAD.EXE""" ;creates link in Accessories folder
[Strings]

APPS_DESC="Accessories"
WORDPAD_LINK="WordPad"
; Directory names - note that that short versions must match the truncated
; 8 char names for the long versions, or else there will be problems.
PROGRAMF="Progra~1" ; first 6 chars of Program_Files, + "~1"
ACCESSOR="Access~1" ; first 6 chars of Accessories, + "~1"

Index


Limitations of INFs

Index