Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RemoveControlByName Function

Removes the registry entries and all of the files associated with the specified control.


HRESULT RemoveControlByName(
    LPCTSTR lpszFile,
    LPCTSTR lpszTypeLibID,
    BOOL bForceRemove,
    DWORD dwIsDistUnit


A LPCTSTR value that contains the full path to the main file of the control (usually the .ocx file).
A LPCTSTR value that contains the class identifier (CLSID) or distribution unit name associated with the control.
A LPCTSTR value that contains the type library CLSID of the control. This can be set to NULL.
A BOOL value that specifies the method used to remove the control. If set to FALSE, the removal routine first checks to see if it is safe to remove the control. If set to TRUE, the control is removed, regardless of the removal status, unless there is a sharing violation. This value only applies to the control file itself.
A DWORD value that specifies if this control is part of a distribution unit. This must be set to TRUE if it is part of a distribution unit, or FALSE otherwise.

Return Value

Returns one of the following values if the control is uninstalled successfully. If the uninstall is aborted, the function returns an error code, and the state of the control is not guaranteed.

S_OK The control was successfully uninstalled.
S_FALSE A minor error occurred, but not serious enough to abort the operation. The control has been uninstalled successfully.


If the control is located in the system directory, the control is not removed, regardless of the value set in the bForceRemove parameter.


This example shows how to call this function.

security note Security Alert  Using LoadLibrary incorrectly can compromise the security of your application by loading the wrong DLL. Refer to the LoadLibrary documentation for information on how to correctly load DLLs with different versions of Windows.

             LPCTSTR lpszFile,
             LPCTSTR lpszCLSID,
             LPCTSTR lpszTypeLibID,
             BOOL bForceRemove = FALSE,
             DWORD dwIsDistUnit = FALSE

HMODULE                   hMod;

hMod = LoadLibrary("OCCACHE.DLL");

if (hMod == NULL)
   // Error loading module -- fail as securely as possible

pfn = (REMOVECONTROLBYNAME)GetProcAddress(hMod, "RemoveControlByName");
if (pfn) {
    (*pfn)(szFileName, szDistributionUnit, NULL, FALSE, TRUE);

Function Information

Stock Implementation occache.dll
Custom Implementation No
Import library None
Minimum availability Internet Explorer 5
Minimum operating systems Windows NT 4.0, Windows 95
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.