Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Content Extensions
ActiveX Controls
Reference
Functions
 RemoveControlByName Function
RemoveControlByName Function

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

Syntax

HRESULT RemoveControlByName(      
    LPCTSTR lpszFile,     LPCTSTR lpszCLSID,     LPCTSTR lpszTypeLibID,     BOOL bForceRemove,     DWORD dwIsDistUnit );

Parameters

lpszFile
A LPCTSTR value that contains the full path to the main file of the control (usually the .ocx file).
lpszCLSID
A LPCTSTR value that contains the class identifier (CLSID) or distribution unit name associated with the control.
lpszTypeLibID
A LPCTSTR value that contains the type library CLSID of the control. This can be set to NULL.
bForceRemove
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.
dwIsDistUnit
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_OKThe control was successfully uninstalled.
S_FALSEA minor error occurred, but not serious enough to abort the operation. The control has been uninstalled successfully.

Remarks

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

Example

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 Microsoft Windows.
typedef HRESULT (WINAPI *REMOVECONTROLBYNAME)(
             LPCTSTR lpszFile,
             LPCTSTR lpszCLSID,
             LPCTSTR lpszTypeLibID,
             BOOL bForceRemove = FALSE,
             DWORD dwIsDistUnit = FALSE
             );

HMODULE                   hMod;
REMOVECONTROLBYNAME       pfn =  NULL;

hMod = LoadLibrary("OCCACHE.DLL");

if (hMod == NULL)
{
   // Error loading module -- fail as securely as possible
   return;
}

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

Function Information

Stock Implementationoccache.dll
Custom ImplementationNo
Import libraryNone
Minimum availabilityInternet Explorer 5
Minimum operating systems Windows NT 4.0, Windows 95
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker