## The MAKENAME Sample

The MAKENAME Sample accompanies Chapter 15 and illustrates how to generate a unique friendly name during a device installation.

The sample includes one component:

- MAKENAME.DLL is a DLL for use as part of a device installation procedure.

### Building MAKENAME

To build MAKENAME.DLL, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project file is named MAKENAME.DSP.

### Testing MAKENAME

You can test MAKENAME as follows. First, select a device that doesn't already have a friendly name in its hardware registry key. Then open a command prompt and execute a command like the following one:

`

C:>rundll32 makename,MakeName "DeviceDesc" "FriendlyName (%d)"

`

Here, DeviceDesc is the device description, exactly as it appears in the target device's hardware registry key, and FriendlyName is a friendly name string. To make up a completely fictitious example, suppose you've got an Acme brand toaster whose DeviceDesc is "Acme model 90240". A plausible experiment to make would be:

`

C:>rundll32 makename,MakeName "Acme model 90240" "Acme Toaster (%d)"

`

### Using MAKENAME

MAKENAME.DLL is intended for use in a RUNDLL32 command that you would install into the RunOnce registry key via statements in your INF file. Your INF file could, for example, contain the following:

`

[DestinationDirs]
MakeNameCopyFiles=11
[DeviceList]
"Acme model 90240"=DriverInstall,*WCO1204
[DriverInstall]
CopyFiles=MakeNameCopyFiles[...]
AddReg=MakeNameAddReg
[DriverInstall.nt]
CopyFiles=MakeNameCopyFiles[...]
AddReg=MakeNameAddReg
[MakeNameCopyFiles]
makename.dll,,,0x60
[MakeNameAddReg]
HKLM,%RUNONCEKEYNAME%,ToasterFriendlyName,,"rundll32 makename,MakeName ""Acme model 90240"" ""Acme Toaster (%d)"""
[Strings]

`RUNONCEKEYNAME="Software\Microsoft\Windows\CurrentVersion\RunOnce"

### What to look for

MakeName.cpp is the important file in this sample.