Sunday, May 23, 2010
Download the executable file from this location
Download the Source Code from this location
When developing ActiveX controls we often find that we leave a myriad of registered controls that clutter our system. Some even have the same name but have different GUID and Dispatch ID's and so forth. In almost all ActiveX containers, when inserting these controls it is almost impossible to distinguish between the two, or three or four different versions.
So we have developed this small application that can help you avoid the command line interface for Regsvr32.exe. You can register and unregister controls and also have a list of all of the controls installed in your system at any given time.
This application is written in Visual C++ 2002 in MFC, and therefore does not need any runtime files and can be used in most computers just by copying the exe file.
Using this code the application gives you a list of all installed ActiveX controls on your system.
HRESULT hr=CoCreateInstance (CLSID_StdComponentCategoriesMgr ,NULL,CLSCTX_INPROC_SERVER,IID_ICatInformation ,(void **)&pCatInfo);
pCatInfo->EnumClassesOfCategories (1,pcatidImpl,0,pcatidReqd ,&pEnumGUID);
int i = 0;
while( (hr= pEnumGUID->Next( 1, &clsid, NULL ))==S_OK )
hr = StringFromCLSID(clsid, &className);
CString sCLSID = className;
CString sPath = "";
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID\\" + sCLSID + "\\InprocServer32"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
TCHAR strValue = _T("");
DWORD dwBufLen = 255;
RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE) strValue, &dwBufLen);
TCHAR strLongPath = _T("");
dwBufLen = 1500;
GetLongPathName(strValue, strLongPath, dwBufLen);
sPath = strLongPath;
lvi.mask = LVIF_TEXT;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)strControlName;
j = m_list2.InsertItem(&lvi);
lvi.iItem = j;
lvi.iSubItem = 1;
lvi.pszText = (LPTSTR)(LPCTSTR)sPath;
i = i + 1;
It also presents you with complete path of the ActiveX control inside your system.
In Windows Vista, Windows 7 Windows Server 2008, Windows 8 and Windows Server 2012 Regsvr32UI.exe must be run as an administrator.