*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
-#include <string.h>
+#define NONAMELESSSTRUCT
+#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
-#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
-#include "winerror.h"
#include "mmsystem.h"
#include "dsound.h"
#include "wine/debug.h"
+#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
+static LSTATUS (WINAPI *pRegDeleteTreeW)(HKEY,LPCWSTR);
+static LSTATUS (WINAPI *pRegDeleteTreeA)(HKEY,LPCSTR);
+
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
static LONG register_progid(WCHAR const *clsid,
char const *progid, char const *curver_progid,
char const *name, char const *extra);
-static LONG recursive_delete_key(HKEY key);
-static LONG recursive_delete_keyA(HKEY base, char const *name);
-static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
/***********************************************************************
* register_interfaces
}
if (list->base_iid) {
- register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
+ res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
- wsprintfW(buf, fmt, list->num_methods);
+ sprintfW(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(lstrlenW(buf) + 1) * sizeof(WCHAR));
}
if (list->ps_clsid) {
- register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
+ res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
- register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
+ res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
- res = recursive_delete_keyW(interface_key, buf);
+ res = pRegDeleteTreeW(interface_key, buf);
+ if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
}
RegCloseKey(interface_key);
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
- res = recursive_delete_keyW(coclass_key, buf);
+ res = pRegDeleteTreeW(coclass_key, buf);
+ if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
- res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
+ res = pRegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
+ if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
if (list->viprogid) {
- res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->viprogid);
+ res = pRegDeleteTreeA(HKEY_CLASSES_ROOT, list->viprogid);
+ if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
return res;
}
-/***********************************************************************
- * recursive_delete_key
- */
-static LONG recursive_delete_key(HKEY key)
-{
- LONG res;
- WCHAR subkey_name[MAX_PATH];
- DWORD cName;
- HKEY subkey;
-
- for (;;) {
- cName = sizeof(subkey_name) / sizeof(WCHAR);
- res = RegEnumKeyExW(key, 0, subkey_name, &cName,
- NULL, NULL, NULL, NULL);
- if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
- res = ERROR_SUCCESS; /* presumably we're done enumerating */
- break;
- }
- res = RegOpenKeyExW(key, subkey_name, 0,
- KEY_READ | KEY_WRITE, &subkey);
- if (res == ERROR_FILE_NOT_FOUND) continue;
- if (res != ERROR_SUCCESS) break;
-
- res = recursive_delete_key(subkey);
- RegCloseKey(subkey);
- if (res != ERROR_SUCCESS) break;
- }
-
- if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
- return res;
-}
-
-/***********************************************************************
- * recursive_delete_keyA
- */
-static LONG recursive_delete_keyA(HKEY base, char const *name)
-{
- LONG res;
- HKEY key;
-
- res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
- if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) return res;
- res = recursive_delete_key(key);
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * recursive_delete_keyW
- */
-static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
-{
- LONG res;
- HKEY key;
-
- res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
- if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) return res;
- res = recursive_delete_key(key);
- RegCloseKey(key);
- return res;
-}
-
/***********************************************************************
* coclass list
*/
/***********************************************************************
* DllRegisterServer (DSOUND.@)
*/
-HRESULT WINAPI DSOUND_DllRegisterServer(void)
+HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr;
/***********************************************************************
* DllUnregisterServer (DSOUND.@)
*/
-HRESULT WINAPI DSOUND_DllUnregisterServer(void)
+HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hr;
+ HMODULE advapi32 = GetModuleHandleA("advapi32");
+ if (!advapi32) return E_FAIL;
+ pRegDeleteTreeA = (void *) GetProcAddress(advapi32, "RegDeleteTreeA");
+ pRegDeleteTreeW = (void *) GetProcAddress(advapi32, "RegDeleteTreeW");
+ if (!pRegDeleteTreeA || !pRegDeleteTreeW) return E_FAIL;
+
TRACE("\n");
hr = unregister_coclasses(coclass_list);