Click to return to the Component Development home page    
Component Development    
Web Workshop  |  Component Development

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
Address of a string value that contains the full path to the main file (usually the .ocx file) of the control.
lpszCLSID
Address of a string value that contains the CLSID or distribution unit name associated with the control.
lpszTypeLibID
Address of a string value that contains the type library CLSID of the control. This can be set to NULL.
bForceRemove
Boolean value that specifies the method used to remove the control. If set to FALSE, the removal routine will first check to see if it is safe to remove the control. If set to TRUE, the control will be removed, regardless of the removal status, unless there is a sharing violation. This value only applies to the control file itself.
dwIsDistUnit
Unsigned long integer 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 will return 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 will not be removed, regardless of the value set in the bForceRemove parameter.

Function Information

Windows NT Use version 4.0
Windows Use Windows 95 and later
Header Not declared in a header file
Import Library No library file
Minimum Availability Internet Explorer 5

Example

This example shows how to call this function.

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) {
    pfn = (REMOVECONTROLBYNAME)GetProcAddress(hMod, "RemoveControlByName");
    if (pfn) {
        (*pfn)(szFileName, szDistributionUnit, NULL, FALSE, TRUE);
    }
    FreeLibrary(hMod);
}


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.