Microsoft KB Archive/242394

= BUG: DeletePrintProcessor on Windows Does Not Delete Print Processor =

Article ID: 242394

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Win32 Application Programming Interface, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows 98 Second Edition

 Microsoft Windows Millennium Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q242394

<div class="notice_section">

IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry

<div class="symptoms_section">

SYMPTOMS
A call to the DeletePrintProcessor function succeeds and returns TRUE, but the print processor remains installed, even after a reboot.

<div class="cause_section">

CAUSE
The DeletePrintProcessor function does nothing on Windows 95, Windows 98, Windows 98 Second Edition, and Windows Millennium Edition when it is routed through the local print provider. Despite doing nothing, it returns TRUE and does not set an error code.

<div class="resolution_section">

RESOLUTION
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

To remove a print processor, delete the appropriately named registry key under:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Environments\Windows 4.0\Print Processors

Deleting the registry entry that refers to the print processor will prevent it from being initialized on the next reboot of the operating system. Once the registry key has been removed, reboot Windows to initialize the spooler process and its print processors.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

MORE INFORMATION
The spooler's DeletePrintProcessor function forwards the function call to the local print provider. The local print provider’s implementation of the DeletePrintProcessor function returns without deleting the print processor.

To work around the problem, an application must remove the registry entries that cause the print processor to be loaded when the operating system starts. The registry key mentioned in this article contains the keys for the installed print processors. Use the name of the print processor given by the PRINTPROCESSOR_INFO_1 structure to locate the registry key and then delete the key with the registry functions or the registry editor. The EnumPrintProcessors function is used to obtain PRINTPROCESSOR_INFO_1 structures.

Deleting the Print Processor's Registry Entry
The following sample code can be used instead of the registry editor to remove the print processor key by its name. NOTE: The warnings included in this article about changing the registry apply also to program code. This code is provided to show how to delete a specific print processor's registry key.

Note that before a print processor registry key is deleted, a careful audit of the installed printers should be performed to ensure that no printer is dependant upon the print processor that is to be deleted. The audit can be done using the EnumPrinters function and the PRINTER_INFO_2 structure.

Note also that this article describes how to prevent the print processor from being loaded at the next reboot of the operating system. Removing the registry entry does not remove the print processor dynamic link library (DLL). The DLL would have to be removed after the operating system has been rebooted, when the DLL is no longer in use. BOOL RegDeletePrintProcessor(LPCSTR pszProcName) {   BOOL    fSuccess = FALSE; HKEY   hPrintProcKey; TCHAR  regKey[MAX_PATH] = "System\\CurrentControlSet\\Control\\Print\\Environments\\Windows 4.0\\Print Processors";

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey, 0, KEY_ALL_ACCESS, &hPrintProcKey) != ERROR_SUCCESS) return FALSE; fSuccess = (ERROR_SUCCESS == RegDeleteKey(hPrintProcKey, pszProcName));

RegCloseKey(hPrintProcKey);

return fSuccess; }

<div class="references_section">