95 static bool launchWebBrowser(const QUrl &url) |
95 static bool launchWebBrowser(const QUrl &url) |
96 { |
96 { |
97 if (url.scheme() == QLatin1String("mailto")) { |
97 if (url.scheme() == QLatin1String("mailto")) { |
98 //Retrieve the commandline for the default mail client |
98 //Retrieve the commandline for the default mail client |
99 //the default key used below is the command line for the mailto: shell command |
99 //the default key used below is the command line for the mailto: shell command |
100 DWORD bufferSize = 2 * MAX_PATH; |
100 DWORD bufferSize = sizeof(wchar_t) * MAX_PATH; |
101 long returnValue = -1; |
101 long returnValue = -1; |
102 QString command; |
102 QString command; |
103 |
103 |
104 HKEY handle; |
104 HKEY handle; |
105 LONG res; |
105 LONG res; |
106 wchar_t keyValue[2 * MAX_PATH] = {0}; |
106 wchar_t keyValue[MAX_PATH] = {0}; |
107 QString keyName(QLatin1String("mailto")); |
107 QString keyName(QLatin1String("mailto")); |
108 |
108 |
109 //Check if user has set preference, otherwise use default. |
109 //Check if user has set preference, otherwise use default. |
110 res = RegOpenKeyExW(HKEY_CURRENT_USER, |
110 res = RegOpenKeyEx(HKEY_CURRENT_USER, |
111 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", |
111 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", |
112 0, KEY_READ, &handle); |
112 0, KEY_READ, &handle); |
113 if (res == ERROR_SUCCESS) { |
113 if (res == ERROR_SUCCESS) { |
114 returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize); |
114 returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize); |
115 if (!returnValue) |
115 if (!returnValue) |
116 keyName = QString::fromUtf16((const ushort*)keyValue); |
116 keyName = QString::fromUtf16((const ushort*)keyValue); |
117 RegCloseKey(handle); |
117 RegCloseKey(handle); |
119 keyName += QLatin1String("\\Shell\\Open\\Command"); |
119 keyName += QLatin1String("\\Shell\\Open\\Command"); |
120 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle); |
120 res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle); |
121 if (res != ERROR_SUCCESS) |
121 if (res != ERROR_SUCCESS) |
122 return false; |
122 return false; |
123 |
123 |
124 bufferSize = 2 * MAX_PATH; |
124 bufferSize = sizeof(wchar_t) * MAX_PATH; |
125 returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize); |
125 returnValue = RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize); |
126 if (!returnValue) |
126 if (!returnValue) |
127 command = QString::fromRawData((QChar*)keyValue, bufferSize); |
127 command = QString::fromRawData((QChar*)keyValue, bufferSize); |
128 RegCloseKey(handle); |
128 RegCloseKey(handle); |
129 |
129 |
130 if (returnValue) |
130 if (returnValue) |