Detlef Riekenberg : wer: Implement Wer*ExcludedApplication.

Alexandre Julliard julliard at winehq.org
Wed Nov 3 11:37:08 CDT 2010


Module: wine
Branch: master
Commit: f47d2118b148418db65f55a9421ceb4079081270
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f47d2118b148418db65f55a9421ceb4079081270

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Tue Nov  2 21:08:54 2010 +0100

wer: Implement Wer*ExcludedApplication.

---

 dlls/wer/Makefile.in |    1 +
 dlls/wer/main.c      |   86 +++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 76 insertions(+), 11 deletions(-)

diff --git a/dlls/wer/Makefile.in b/dlls/wer/Makefile.in
index e90dcc0..6916c19 100644
--- a/dlls/wer/Makefile.in
+++ b/dlls/wer/Makefile.in
@@ -1,5 +1,6 @@
 MODULE    = wer.dll
 IMPORTLIB = wer
+IMPORTS   = advapi32
 
 C_SRCS = \
 	main.c
diff --git a/dlls/wer/main.c b/dlls/wer/main.c
index 539eac4..d78da3e 100644
--- a/dlls/wer/main.c
+++ b/dlls/wer/main.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2010 Louis Lenders
+ * Copyright 2010 Detlef Riekenberg
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,8 +23,10 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "winreg.h"
 #include "werapi.h"
 #include "wine/list.h"
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wer);
@@ -47,6 +50,11 @@ static CRITICAL_SECTION report_table_cs = { &report_table_cs_debug, -1, 0, 0, 0,
 
 static struct list report_table = LIST_INIT(report_table);
 
+static WCHAR regpath_exclude[] = {'S','o','f','t','w','a','r','e','\\',
+                                  'M','i','c','r','o','s','o','f','t','\\',
+                                  'W','i','n','d','o','w','s',' ','E','r','r','o','r',' ','R','e','p','o','r','t','i','n','g','\\',
+                                  'E','x','c','l','u','d','e','d','A','p','p','l','i','c','a','t','i','o','n','s',0};
+
 /***********************************************************************
  * Memory alloccation helper
  */
@@ -61,12 +69,6 @@ static inline BOOL heap_free(void *mem)
     return HeapFree(GetProcessHeap(), 0, mem);
 }
 
-HRESULT WINAPI WerAddExcludedApplication(PCWSTR exeName, BOOL allUsers)
-{
-    FIXME("(%s, %d) stub\n",debugstr_w(exeName), allUsers);
-    return E_NOTIMPL;
-}
-
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
@@ -86,6 +88,47 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 }
 
 /***********************************************************************
+ * WerAddExcludedApplication (wer.@)
+ *
+ * Add an application to the user specific or the system wide exclusion list
+ *
+ * PARAMS
+ *  exeName  [i] The application name
+ *  allUsers [i] for all users (TRUE) or for the current user (FALSE)
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Faulure: A HRESULT error code
+ *
+ */
+HRESULT WINAPI WerAddExcludedApplication(PCWSTR exeName, BOOL allUsers)
+{
+    HKEY hkey;
+    DWORD value = 1;
+    LPWSTR bs;
+
+    TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
+    if (!exeName || !exeName[0])
+        return E_INVALIDARG;
+
+    bs = strrchrW(exeName, '\\');
+    if (bs) {
+        bs++;   /* skip the backslash */
+        if (!bs[0]) {
+            return E_INVALIDARG;
+        }
+    } else
+        bs = (LPWSTR) exeName;
+
+    if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
+        RegSetValueExW(hkey, bs, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
+        RegCloseKey(hkey);
+        return S_OK;
+    }
+    return E_ACCESSDENIED;
+}
+
+/***********************************************************************
  * WerRemoveExcludedApplication (wer.@)
  *
  * remove an application from the exclusion list
@@ -94,15 +137,36 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  *  exeName  [i] The application name
  *  allUsers [i] for all users (TRUE) or for the current user (FALSE)
  *
- * RESULTS
- *  SUCCESS  S_OK
- *  FAILURE  A HRESULT error code
+ * RETURNS
+ *  Success: S_OK
+ *  Faulure: A HRESULT error code
  *
  */
 HRESULT WINAPI WerRemoveExcludedApplication(PCWSTR exeName, BOOL allUsers)
 {
-    FIXME("(%s, %d) :stub\n",debugstr_w(exeName), allUsers);
-    return E_NOTIMPL;
+    HKEY hkey;
+    LPWSTR bs;
+    LONG lres;
+
+    TRACE("(%s, %d)\n",debugstr_w(exeName), allUsers);
+    if (!exeName || !exeName[0])
+        return E_INVALIDARG;
+
+    bs = strrchrW(exeName, '\\');
+    if (bs) {
+        bs++;   /* skip the backslash */
+        if (!bs[0]) {
+            return E_INVALIDARG;
+        }
+    } else
+        bs = (LPWSTR) exeName;
+
+    if (!RegCreateKeyW(allUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, regpath_exclude, &hkey)) {
+        lres = RegDeleteValueW(hkey, bs);
+        RegCloseKey(hkey);
+        return lres ? __HRESULT_FROM_WIN32(ERROR_ENVVAR_NOT_FOUND) : S_OK;
+    }
+    return E_ACCESSDENIED;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list