diff --git a/dlls/mapi32/tests/Makefile.in b/dlls/mapi32/tests/Makefile.in index 6c4482e877..bd3c1a1a9a 100644 --- a/dlls/mapi32/tests/Makefile.in +++ b/dlls/mapi32/tests/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = mapi32.dll -IMPORTS = kernel32 +IMPORTS = advapi32 kernel32 CTESTS = \ imalloc.c \ diff --git a/dlls/mapi32/tests/imalloc.c b/dlls/mapi32/tests/imalloc.c index ec7557bc11..485180c0e4 100644 --- a/dlls/mapi32/tests/imalloc.c +++ b/dlls/mapi32/tests/imalloc.c @@ -26,6 +26,7 @@ #include "winerror.h" #include "winnt.h" #include "mapiutil.h" +#include "mapi32_test.h" static HMODULE hMapi32 = 0; @@ -88,6 +89,12 @@ START_TEST(imalloc) { SCODE ret; + if (!HaveDefaultMailClient()) + { + win_skip("No default mail client installed\n"); + return; + } + hMapi32 = LoadLibraryA("mapi32.dll"); pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); diff --git a/dlls/mapi32/tests/mapi32_test.h b/dlls/mapi32/tests/mapi32_test.h new file mode 100644 index 0000000000..5002dbc99b --- /dev/null +++ b/dlls/mapi32/tests/mapi32_test.h @@ -0,0 +1,62 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * Return FALSE if no default mail client is installed. + */ +static BOOL HaveDefaultMailClient(void) +{ + HKEY Key; + DWORD Type, Size; + BYTE Buffer[64]; + BOOL HasHKCUKey; + + /* We check the default value of both HKCU\Software\Clients\Mail and + * HKLM\Software\Clients\Mail, if one of them is present there is a default + * mail client. If neither of these keys is present, we might be running + * on an old Windows version (W95, NT4) and we assume a default mail client + * might be available. Only if one of the keys is present, but there is + * no default value do we assume there is no default client. */ + if (RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS) + { + Size = sizeof(Buffer); + /* Any return value besides ERROR_FILE_NOT_FOUND (including success, + ERROR_MORE_DATA) indicates the value is present */ + if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND) + { + RegCloseKey(Key); + return TRUE; + } + RegCloseKey(Key); + HasHKCUKey = TRUE; + } + else + HasHKCUKey = FALSE; + + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS) + { + Size = sizeof(Buffer); + if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND) + { + RegCloseKey(Key); + return TRUE; + } + RegCloseKey(Key); + return FALSE; + } + + return ! HasHKCUKey; +} diff --git a/dlls/mapi32/tests/prop.c b/dlls/mapi32/tests/prop.c index 8f4ff1ef05..237134b07c 100644 --- a/dlls/mapi32/tests/prop.c +++ b/dlls/mapi32/tests/prop.c @@ -27,6 +27,7 @@ #include "initguid.h" #include "mapiutil.h" #include "mapitags.h" +#include "mapi32_test.h" static HMODULE hMapi32 = 0; @@ -1360,6 +1361,12 @@ START_TEST(prop) { SCODE ret; + if (!HaveDefaultMailClient()) + { + win_skip("No default mail client installed\n"); + return; + } + if(!InitFuncPtrs()) { win_skip("Needed functions are not available\n"); diff --git a/dlls/mapi32/tests/util.c b/dlls/mapi32/tests/util.c index af4fc57c7a..feb2c6daa0 100644 --- a/dlls/mapi32/tests/util.c +++ b/dlls/mapi32/tests/util.c @@ -26,6 +26,7 @@ #include "winnt.h" #include "mapiutil.h" #include "mapitags.h" +#include "mapi32_test.h" static HMODULE hMapi32 = 0; @@ -172,6 +173,12 @@ START_TEST(util) { SCODE ret; + if (!HaveDefaultMailClient()) + { + win_skip("No default mail client installed\n"); + return; + } + hMapi32 = LoadLibraryA("mapi32.dll"); pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");