Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 17762 → Rev 17763

/trunk/Scribus/scribus/util_ghostscript.cpp
41,7 → 41,13
 
#if defined(_WIN32)
#include <windows.h>
#ifndef KEY_WOW64_32KEY
#define KEY_WOW64_32KEY (0x0200)
#endif
#ifndef KEY_WOW64_64KEY
#define KEY_WOW64_64KEY (0x0100)
#endif
#endif
 
#include "prefsfile.h"
#include "prefsmanager.h"
267,10 → 273,30
// Set gsName to its default value
gsName = "gswin32c.exe";
 
QMap<int, QString> gplGS = getGSExePaths("SOFTWARE\\GPL Ghostscript");
QMap<int, QString> afplGS = getGSExePaths("SOFTWARE\\AFPL Ghostscript");
QMap<int, QString> gsVersions = gplGS.unite(afplGS);
// Test is we are running a 64bit version of WINDOWS
bool isWindows64 = false;
wchar_t* procArch = _wgetenv(L"PROCESSOR_ARCHITECTURE");
if (procArch)
{
isWindows64 |= (wcscmp(procArch, L"AMD64") == 0);
isWindows64 |= (wcscmp(procArch, L"IA64") == 0);
}
wchar_t* procArchWow64 = _wgetenv(L"PROCESSOR_ARCHITEW6432");
if (procArchWow64) isWindows64 = true;
 
// Search for Ghostsscript executable in native registry
QMap<int, QString> gsVersions;
gsVersions.unite( getGSExePaths("SOFTWARE\\GPL Ghostscript") );
gsVersions.unite( getGSExePaths("SOFTWARE\\AFPL Ghostscript") );
 
// If running on Windows 64bit, search alternate registry view,
// ie 32bit registry if process is 64bit, 64bit registry if process is 32bit
if (isWindows64)
{
gsVersions.unite( getGSExePaths("SOFTWARE\\GPL Ghostscript", true) );
gsVersions.unite( getGSExePaths("SOFTWARE\\AFPL Ghostscript", true) );
}
 
if (gsVersions.isEmpty())
return gsName;
 
308,7 → 334,7
return gsName;
}
 
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey)
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey, bool alternateView)
{
QMap<int, QString> gsVersions;
#if defined _WIN32
316,22 → 342,35
DWORD size;
HKEY hKey1, hKey2;
DWORD regType = REG_SZ;
REGSAM flags = KEY_READ;
WCHAR regVersion[MAX_PATH];
WCHAR regPath[MAX_PATH];
WCHAR gsPath[MAX_PATH];
QString gsVersion, gsName;
QString gsVersion, gsExeName, gsName;
 
if( RegOpenKeyW(HKEY_LOCAL_MACHINE, (LPCWSTR) regKey.utf16(), &hKey1) == ERROR_SUCCESS )
bool isWin64Api = false;
#if defined(_WIN64)
isWin64Api = true;
#endif
 
gsExeName = isWin64Api ? "gswin64c.exe" : "gswin32c.exe";
if (alternateView)
{
gsExeName = isWin64Api ? "gswin32c.exe" : "gswin64c.exe";
flags |= (isWin64Api ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
}
 
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCWSTR) regKey.utf16(), 0, flags, &hKey1) == ERROR_SUCCESS)
{
size = sizeof(regVersion)/sizeof(WCHAR) - 1;
DWORD keyIndex = 0;
while ( RegEnumKeyExW(hKey1, keyIndex, regVersion, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS )
while (RegEnumKeyExW(hKey1, keyIndex, regVersion, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
int gsNumericVer, gsMajor, gsMinor;
wcscpy(regPath, (const wchar_t*) regKey.utf16());
wcscat(regPath, L"\\");
wcscat(regPath, regVersion);
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, regPath, &hKey2) == ERROR_SUCCESS)
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, regPath, 0, flags, &hKey2) == ERROR_SUCCESS)
{
size = sizeof(gsPath) - 1;
if (RegQueryValueExW(hKey2, L"GS_DLL", 0, &regType, (LPBYTE) gsPath, &size) == ERROR_SUCCESS)
346,7 → 385,7
if (size > 0)
{
gsName = gsName.left(size + 1);
gsName += "gswin32c.exe";
gsName += gsExeName;
gsName.replace("\\", "/");
gsVersions.insert(gsNumericVer, gsName);
}
/trunk/Scribus/scribus/util_ghostscript.h
52,5 → 52,5
bool SCRIBUS_API getNumericGSVersion(int & major, int & minor);
bool SCRIBUS_API getNumericGSVersion(const QString& ver, int&major, int& minor);
QString SCRIBUS_API getGSDefaultExeName(void);
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey);
QMap<int, QString> SCRIBUS_API getGSExePaths(const QString& regKey, bool alternateView = false);
#endif