266
272
// Set gsName to its default value
267
273
gsName = "gswin32c.exe";
269
QMap<int, QString> gplGS = getGSExePaths("SOFTWARE\\GPL Ghostscript");
270
QMap<int, QString> afplGS = getGSExePaths("SOFTWARE\\AFPL Ghostscript");
271
QMap<int, QString> gsVersions = gplGS.unite(afplGS);
275
// Test is we are running a 64bit version of WINDOWS
276
bool isWindows64 = false;
277
wchar_t* procArch = _wgetenv(L"PROCESSOR_ARCHITECTURE");
280
isWindows64 |= (wcscmp(procArch, L"AMD64") == 0);
281
isWindows64 |= (wcscmp(procArch, L"IA64") == 0);
283
wchar_t* procArchWow64 = _wgetenv(L"PROCESSOR_ARCHITEW6432");
284
if (procArchWow64) isWindows64 = true;
286
// Search for Ghostsscript executable in native registry
287
QMap<int, QString> gsVersions;
288
gsVersions.unite( getGSExePaths("SOFTWARE\\GPL Ghostscript") );
289
gsVersions.unite( getGSExePaths("SOFTWARE\\AFPL Ghostscript") );
291
// If running on Windows 64bit, search alternate registry view,
292
// ie 32bit registry if process is 64bit, 64bit registry if process is 32bit
295
gsVersions.unite( getGSExePaths("SOFTWARE\\GPL Ghostscript", true) );
296
gsVersions.unite( getGSExePaths("SOFTWARE\\AFPL Ghostscript", true) );
273
299
if (gsVersions.isEmpty())
310
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey)
336
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey, bool alternateView)
312
338
QMap<int, QString> gsVersions;
313
339
#if defined _WIN32
316
342
HKEY hKey1, hKey2;
317
343
DWORD regType = REG_SZ;
344
REGSAM flags = KEY_READ;
318
345
WCHAR regVersion[MAX_PATH];
319
346
WCHAR regPath[MAX_PATH];
320
347
WCHAR gsPath[MAX_PATH];
321
QString gsVersion, gsName;
323
if( RegOpenKeyW(HKEY_LOCAL_MACHINE, (LPCWSTR) regKey.utf16(), &hKey1) == ERROR_SUCCESS )
348
QString gsVersion, gsExeName, gsName;
350
bool isWin64Api = false;
355
gsExeName = isWin64Api ? "gswin64c.exe" : "gswin32c.exe";
358
gsExeName = isWin64Api ? "gswin32c.exe" : "gswin64c.exe";
359
flags |= (isWin64Api ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
362
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCWSTR) regKey.utf16(), 0, flags, &hKey1) == ERROR_SUCCESS)
325
364
size = sizeof(regVersion)/sizeof(WCHAR) - 1;
326
365
DWORD keyIndex = 0;
327
while ( RegEnumKeyExW(hKey1, keyIndex, regVersion, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS )
366
while (RegEnumKeyExW(hKey1, keyIndex, regVersion, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
329
368
int gsNumericVer, gsMajor, gsMinor;
330
369
wcscpy(regPath, (const wchar_t*) regKey.utf16());
331
370
wcscat(regPath, L"\\");
332
371
wcscat(regPath, regVersion);
333
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, regPath, &hKey2) == ERROR_SUCCESS)
372
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, regPath, 0, flags, &hKey2) == ERROR_SUCCESS)
335
374
size = sizeof(gsPath) - 1;
336
375
if (RegQueryValueExW(hKey2, L"GS_DLL", 0, ®Type, (LPBYTE) gsPath, &size) == ERROR_SUCCESS)
347
386
gsName = gsName.left(size + 1);
348
gsName += "gswin32c.exe";
349
388
gsName.replace("\\", "/");
350
389
gsVersions.insert(gsNumericVer, gsName);