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 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.
Return code | Description |
---|---|
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.
Examples
This example shows how to call this function.
Security Warning: 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);
}
Requirements
Minimum supported client |
Windows XP |
Minimum supported server |
Windows 2000 Server |
Header |
N/A |
DLL |
Occache.dll |