Patch level :4.0 setup
Files correlati : Ricompilazione Demo : [ ] Commento :modalita' di esecuzione server controllo registry! git-svn-id: svn://10.65.10.50/trunk@15554 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5996c599ef
commit
6c5153c93e
124
setup/Setup.cpp
124
setup/Setup.cpp
@ -30,13 +30,13 @@ extern "C"
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
bool ErrorBox(LPCSTR str)
|
||||
bool ErrorBox(const wxString str)
|
||||
{
|
||||
wxMessageBox(str, APPNAME, wxOK | wxICON_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WarningBox(LPCSTR str)
|
||||
bool WarningBox(const wxString str)
|
||||
{
|
||||
wxMessageBox(str, APPNAME, wxOK | wxICON_EXCLAMATION);
|
||||
return false;
|
||||
@ -139,34 +139,8 @@ bool CampoDirCopier::Copy(const wxString& src, const wxString& dst, bool bOpenGL
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
bool WriteRootRegistryKey(const wxChar* strKey, const wxString& strValue)
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
DWORD dw = 0;
|
||||
bool ok = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, strKey, 0, REG_NONE,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, &hKey, &dw) == ERROR_SUCCESS;
|
||||
if (ok)
|
||||
{
|
||||
ok = ::RegSetValueEx(hKey, NULL, 0, REG_SZ,
|
||||
(BYTE*)(const wxChar*)strValue, DWORD(2*strValue.Len()+2)) == ERROR_SUCCESS;
|
||||
::RegCloseKey(hKey);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void AssociateExtension(const wxFileName& strExeFile, const wxChar* strExt)
|
||||
{
|
||||
// Register icon and application
|
||||
WriteRootRegistryKey(strExt, APPNAME);
|
||||
|
||||
wxString str = strExeFile.GetFullPath(); str += wxT(",0");
|
||||
WriteRootRegistryKey(wxT("Campo\\DefaultIcon"), str);
|
||||
|
||||
str = strExeFile.GetFullPath(); str += wxT(" \"%1\"");
|
||||
WriteRootRegistryKey(wxT("Campo\\shell\\open\\command"), str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -256,7 +230,8 @@ public:
|
||||
};
|
||||
|
||||
CampoIniFile::CampoIniFile(const wxString strIniPath, const wxString strParagraph)
|
||||
: wxFileConfig ("", "", "", strIniPath, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_NO_ESCAPE_CHARACTERS)
|
||||
: wxFileConfig (wxEmptyString, wxEmptyString, wxEmptyString, strIniPath,
|
||||
wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_NO_ESCAPE_CHARACTERS)
|
||||
{
|
||||
if (!strParagraph.IsEmpty())
|
||||
SetPath(strParagraph);
|
||||
@ -1929,11 +1904,21 @@ class CampoSetup : public wxApp
|
||||
CampoFrame* m_pMainFrame;
|
||||
wxLocale m_locale;
|
||||
|
||||
private:
|
||||
bool WriteRegistryKey(HKEY hBaseKey, const wxString strKey, const wxString& strValue) const;
|
||||
wxString ReadRegistryKey(HKEY hBaseKey, const wxString strKey) const;
|
||||
|
||||
protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
void OnTimer(wxTimerEvent& e);
|
||||
bool CreateIcon(unsigned int csidl, const wxFileName& strExeFile) const;
|
||||
bool CreateAutostartMode(const int iSrvAutostartMode, const wxString& strPath);
|
||||
void AssociateExtension(const wxFileName& strExeFile, const wxString strExt);
|
||||
|
||||
wxString ReadRootRegistryKey(const wxString strKey) const;
|
||||
wxString ReadLocalMachineRegistryKey(const wxString strKey) const;
|
||||
bool WriteRootRegistryKey(const wxString strKey, const wxString& strValue) const;
|
||||
bool WriteLocalMachineRegistryKey(const wxString strKey, const wxString& strValue) const;
|
||||
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
@ -1945,11 +1930,90 @@ BEGIN_EVENT_TABLE(CampoSetup, wxApp)
|
||||
EVT_TIMER(883, OnTimer)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//metodi di lettura/scrittura registry di windows (fantastici!)
|
||||
wxString CampoSetup::ReadRegistryKey(HKEY hBaseKey, const wxString strKey) const
|
||||
{
|
||||
wxString strValue;
|
||||
HKEY hKey = NULL;
|
||||
wxString strPath, strName;
|
||||
wxFileName::SplitPath(strKey, &strPath, &strName, NULL);
|
||||
|
||||
bool ok = ::RegOpenKeyEx(hBaseKey, strPath, 0, KEY_READ, &hKey) == ERROR_SUCCESS;
|
||||
if (ok)
|
||||
{
|
||||
BYTE buff[512];
|
||||
DWORD type = REG_SZ;
|
||||
DWORD dw = sizeof(buff);
|
||||
ok = ::RegQueryValueEx(hKey, strName, NULL, &type, buff, &dw) == ERROR_SUCCESS;
|
||||
if (ok)
|
||||
strValue = buff;
|
||||
::RegCloseKey(hKey);
|
||||
}
|
||||
return strValue;
|
||||
}
|
||||
|
||||
wxString CampoSetup::ReadRootRegistryKey(const wxString strKey) const
|
||||
{
|
||||
return ReadRegistryKey(HKEY_CLASSES_ROOT, strKey);
|
||||
}
|
||||
|
||||
wxString CampoSetup::ReadLocalMachineRegistryKey(const wxString strKey) const
|
||||
{
|
||||
return ReadRegistryKey(HKEY_LOCAL_MACHINE, strKey);
|
||||
}
|
||||
|
||||
bool CampoSetup::WriteRegistryKey(HKEY hBaseKey, const wxString strKey, const wxString& strValue) const
|
||||
{
|
||||
HKEY hKey = NULL;
|
||||
DWORD dw = 0;
|
||||
bool ok = ::RegCreateKeyEx(hBaseKey, strKey, 0, REG_NONE,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, &hKey, &dw) == ERROR_SUCCESS;
|
||||
if (ok)
|
||||
{
|
||||
ok = ::RegSetValueEx(hKey, NULL, 0, REG_SZ,
|
||||
(BYTE*)(const wxChar*)strValue, DWORD(2*strValue.Len()+2)) == ERROR_SUCCESS;
|
||||
::RegCloseKey(hKey);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool CampoSetup::WriteRootRegistryKey(const wxString strKey, const wxString& strValue) const
|
||||
{
|
||||
return WriteRegistryKey(HKEY_CLASSES_ROOT, strKey, strValue);
|
||||
}
|
||||
|
||||
bool CampoSetup::WriteLocalMachineRegistryKey(const wxString strKey, const wxString& strValue) const
|
||||
{
|
||||
return WriteRegistryKey(HKEY_LOCAL_MACHINE, strKey, strValue);
|
||||
}
|
||||
|
||||
void CampoSetup::AssociateExtension(const wxFileName& strExeFile, const wxString strExt)
|
||||
{
|
||||
// Register icon and application
|
||||
WriteRootRegistryKey(strExt, APPNAME);
|
||||
|
||||
wxString str = strExeFile.GetFullPath(); str += wxT(",0");
|
||||
WriteRootRegistryKey(wxT("Campo\\DefaultIcon"), str);
|
||||
|
||||
str = strExeFile.GetFullPath(); str += wxT(" \"%1\"");
|
||||
WriteRootRegistryKey(wxT("Campo\\shell\\open\\command"), str);
|
||||
}
|
||||
|
||||
bool CampoSetup::CreateAutostartMode(const int iSrvAutostartMode, const wxString& strPath)
|
||||
{
|
||||
switch (iSrvAutostartMode)
|
||||
{
|
||||
//esecuzione server come servizi (magia!)
|
||||
case 0:
|
||||
{
|
||||
wxString strValue = ReadLocalMachineRegistryKey("SOFTWARE\\Jasc\\Paint Shop Pro 8\\Installer\\InstallDirectory");
|
||||
if (strValue.IsEmpty())
|
||||
{
|
||||
const wxString strCreateService = "./setup/instsrv.exe lerch ./setup/srvany.exe";
|
||||
wxExecute(strCreateService, wxEXEC_SYNC);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//link nella cartella esecuzione automatica
|
||||
case 1:
|
||||
{
|
||||
@ -1957,9 +2021,7 @@ bool CampoSetup::CreateAutostartMode(const int iSrvAutostartMode, const wxString
|
||||
CreateIcon(CSIDL_COMMON_STARTUP, strPath);
|
||||
}
|
||||
break;
|
||||
//esecuzione server come servizi (magia!)
|
||||
default:
|
||||
const wxString strCreateService = "./setup/instsrv.exe lerch ./setup/srvany.exe";
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user