Paul Vriens : advapi32/service: Test for duplicate displayname.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 18 06:57:31 CDT 2007
Module: wine
Branch: master
Commit: f8ea5a73ce799ae7a8b8e3d9d5ae9d28511c1d8b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f8ea5a73ce799ae7a8b8e3d9d5ae9d28511c1d8b
Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date: Tue Jul 17 22:06:51 2007 +0200
advapi32/service: Test for duplicate displayname.
---
dlls/advapi32/tests/service.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index 9157dea..4013988 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -144,6 +144,10 @@ static void test_create_delete_svc(void)
static const CHAR empty [] = "";
static const CHAR spooler [] = "Spooler"; /* Should be available on all platforms */
static const CHAR password [] = "secret";
+ BOOL spooler_exists = FALSE;
+ BOOL ret;
+ CHAR display[4096];
+ DWORD display_size = sizeof(display);
/* Get the username and turn it into an account to be used in some tests */
GetUserNameA(username, &user_size);
@@ -277,6 +281,7 @@ static void test_create_delete_svc(void)
svc_handle1 = OpenServiceA(scm_handle, spooler, GENERIC_READ);
if (svc_handle1)
{
+ spooler_exists = TRUE;
CloseServiceHandle(svc_handle1);
SetLastError(0xdeadbeef);
svc_handle1 = CreateServiceA(scm_handle, spooler, NULL, 0, SERVICE_WIN32_OWN_PROCESS, SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, NULL, NULL);
@@ -286,7 +291,35 @@ static void test_create_delete_svc(void)
else
skip("Spooler service doesn't exist\n");
- /* TODO: Add check for displayname, it must be unique (or NULL/empty) */
+ /* To find an existing displayname we check the 'Spooler' service. Although the registry doesn't show DisplayName on NT4, this call
+ * will return a displayname which is equal to the servicename and can't be used as well for a new displayname.
+ */
+ if (spooler_exists)
+ {
+ ret = GetServiceDisplayNameA(scm_handle, spooler, display, &display_size);
+
+ if (!ret)
+ skip("Could not retrieve a displayname for the Spooler service\n");
+ else
+ {
+ svc_handle1 = CreateServiceA(scm_handle, servicename, display, 0, SERVICE_WIN32_OWN_PROCESS, SERVICE_DISABLED, 0,
+ pathname, NULL, NULL, NULL, NULL, NULL);
+ todo_wine
+ {
+ ok(!svc_handle1, "Expected failure\n");
+ ok(GetLastError() == ERROR_DUPLICATE_SERVICE_NAME, "Expected ERROR_DUPLICATE_SERVICE_NAME, got %d\n", GetLastError());
+ }
+ }
+ }
+ else
+ skip("Could not retrieve a displayname (Spooler service doesn't exist)\n");
+
+ /* FIXME: Remove this when Wine is fixed */
+ if (svc_handle1)
+ {
+ DeleteService(svc_handle1);
+ CloseServiceHandle(svc_handle1);
+ }
CloseServiceHandle(scm_handle);
}
More information about the wine-cvs
mailing list