unsigned long int RemoveRegistrySubkeys (HKEY hkMainKey, unsigned short int* psKeyName, unsigned short int* psSubKeysNameBegin) { HKEY hkKey; if (RegOpenKeyEx(hkMainKey, psKeyName, 0, 0, &hkKey)) { return (0); } unsigned long int iCount; RegQueryInfoKey(hkKey, NULL, NULL, NULL, &iCount, NULL, NULL, NULL, NULL, NULL, NULL, NULL); unsigned long int iRemoved = 0; while (iCount) { unsigned short int sKeyName[256]; unsigned long int iSize = 256; RegEnumKeyEx(hkKey, --iCount, sKeyName, &iSize, NULL, NULL, NULL, NULL); if (wcsncmp(sKeyName, psSubKeysNameBegin, wcslen(psSubKeysNameBegin))) { continue; } RegDeleteKey(hkKey, sKeyName); iRemoved ++; } return (iRemoved); } unsigned long int RemoveRegistryValues (HKEY hkMainKey, unsigned short int* psKeyName, unsigned short int* psValuesNameBegin) { HKEY hkKey; if (RegOpenKeyEx(hkMainKey, psKeyName, 0, 0, &hkKey)) { return (0); } unsigned long int iCount; RegQueryInfoKey(hkKey, NULL, NULL, NULL, NULL, NULL, NULL, &iCount, NULL, NULL, NULL, NULL); unsigned long int iRemoved = 0; while (iCount) { unsigned short int sValueName[256]; unsigned long int iSize = 256; RegEnumValue(hkKey, --iCount, sValueName, &iSize, NULL, NULL, NULL, NULL); if (wcsncmp(sValueName, psValuesNameBegin, wcslen(psValuesNameBegin))) { continue; } RegDeleteValue(hkKey, sValueName); iRemoved ++; } return (iRemoved); } unsigned long UnregisterSDF12() { unsigned long int iRemoved = 0; iRemoved += (RegDeleteKey(HKEY_LOCAL_MACHINE, L"Software\\Apps\\OpenNETCF SDF v1.2") == 0); iRemoved += (RegDeleteKey(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\.NETCompactFramework\\Installer\\Assemblies\\3rdParty\\OpenNETCF.SDF.1.2.gac") == 0); iRemoved += RemoveRegistryValues(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\.NETCompactFramework\\Installer\\Assemblies\\Global", L"OpenNETCF"); iRemoved += RemoveRegistrySubkeys(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\.NETCompactFramework\\Installer\\Assemblies\\Reference", L"OpenNETCF"); return (iRemoved); }