WORD DevInstall(hWnd, lpModelName, OldPort, NewPort) | |||
HWND hWnd; | |||
LPSTR lpModelName; | |||
LPSTR OldPort; | |||
LPSTR NewPort; |
The DevInstall function changes port connections, and installs and removes
printers. Control Panel calls this function whenever the user switches the port for
a printer model.
hWnd
Identifies the parent window to use for any dialog boxes the function creates.
lpModelName
Points to a null-terminated string specifying the name of the current printer model.
OldPort
Points to a null-terminated string specifying the name of the port being changed. If the OldPort parameter is NULL, the function installs the new printer model.
NewPort
Points to a null-terminated string specifying the name of the port to be changed to. If the NewPort parameter is NULL, the function removes printer model.
The return value is one of the following values.
Value | Meaning |
1 | Succeeded |
0 | Doesn't support this function |
-1 | Failed for unknown reason |
When the function changes a port, it must change the port in the [ModelName, Port] section of the WIN.INI file. Also, the function should check for a font section with valid entries for the old port. If there are fonts, the function should warn the user with a message informing them that there are printer fonts installed for the old port. The user can install them using the Fonts button from the Printer Setup dialog box.
When installing a new printer, the function must scan the WIN.INI file for a [DriverName, NewPort] section. If one is found and ModelName matches the printer index listed there, the function creates a new section [ModelName,
NewPort] and moves all nonfont-related information from the [DriverName, Newport] section to this new [ModelName, NewPort] section. After this opera-tion, the [DriverName, NewPort] section contains only the printer fonts listing. If the function doesn't find a [DeviceName, NewPort] section, no action is required.
When removing a printer, the function must remove the [ModelName, OldPort] section including all settings there, but it must not remove the [DriverName, OldPort] section. Other models may be using fonts installed on this port.