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.

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_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.

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 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 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

ADD
Show:
© 2014 Microsoft. All rights reserved.