1 /* 2 * This library is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU Lesser General Public 4 * License as published by the Free Software Foundation; either 5 * version 2.1 of the License, or (at your option) any later version. 6 * 7 * This library is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 * Lesser General Public License for more details. 11 * 12 * You should have received a copy of the GNU Lesser General Public 13 * License along with this library; if not, write to the Free Software 14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 15 */ 16 17 /* 18 * Return FALSE if no default mail client is installed. 19 */ 20 static BOOL HaveDefaultMailClient(void) 21 { 22 HKEY Key; 23 DWORD Type, Size; 24 BYTE Buffer[64]; 25 BOOL HasHKCUKey; 26 27 /* We check the default value of both HKCU\Software\Clients\Mail and 28 * HKLM\Software\Clients\Mail, if one of them is present there is a default 29 * mail client. If neither of these keys is present, we might be running 30 * on an old Windows version (W95, NT4) and we assume a default mail client 31 * might be available. Only if one of the keys is present, but there is 32 * no default value do we assume there is no default client. */ 33 if (RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS) 34 { 35 Size = sizeof(Buffer); 36 /* Any return value besides ERROR_FILE_NOT_FOUND (including success, 37 ERROR_MORE_DATA) indicates the value is present */ 38 if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND) 39 { 40 RegCloseKey(Key); 41 return TRUE; 42 } 43 RegCloseKey(Key); 44 HasHKCUKey = TRUE; 45 } 46 else 47 HasHKCUKey = FALSE; 48 49 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS) 50 { 51 Size = sizeof(Buffer); 52 if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND) 53 { 54 RegCloseKey(Key); 55 return TRUE; 56 } 57 RegCloseKey(Key); 58 return FALSE; 59 } 60 61 return ! HasHKCUKey; 62 } 63