Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@15566 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-08-20 15:50:49 +00:00
parent 0ca3c99f15
commit 3feeb4ce9f

View File

@ -1431,7 +1431,7 @@ CampoWizardPage8::CampoWizardPage8(wxWizard* parent) : CampoWizardPage(parent)
/**********************************************************************************************************/
// 9 pagina con la creazione icona sul desktop e lanciatore del lerch
// 9 pagina con la creazione icona sul desktop e lanciatore del lurch
/**********************************************************************************************************/
class CampoWizardPage9 : public CampoWizardPage
{
@ -1907,6 +1907,7 @@ class CampoSetup : public wxApp
private:
bool WriteRegistryKey(HKEY hBaseKey, const wxString strKey, const wxString& strValue) const;
wxString ReadRegistryKey(HKEY hBaseKey, const wxString strKey) const;
wxString GetFolderPath(unsigned int uPathID) const;
protected:
DECLARE_EVENT_TABLE()
@ -1966,12 +1967,16 @@ bool CampoSetup::WriteRegistryKey(HKEY hBaseKey, const wxString strKey, const wx
{
HKEY hKey = NULL;
DWORD dw = 0;
bool ok = ::RegCreateKeyEx(hBaseKey, strKey, 0, REG_NONE,
//splitta la stringa in path e valore
wxString strPath, strName;
wxFileName::SplitPath(strKey, &strPath, &strName, NULL);
bool ok = ::RegCreateKeyEx(hBaseKey, strPath, 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;
ok = ::RegSetValueEx(hKey, strName, 0, REG_SZ,
(BYTE*)(const wxChar*)strValue, DWORD(2*strValue.Len()+2)) == ERROR_SUCCESS;
::RegCloseKey(hKey);
}
return ok;
@ -1987,6 +1992,13 @@ bool CampoSetup::WriteLocalMachineRegistryKey(const wxString strKey, const wxStr
return WriteRegistryKey(HKEY_LOCAL_MACHINE, strKey, strValue);
}
wxString CampoSetup::GetFolderPath(unsigned int uPathID) const
{
TCHAR szPath[MAX_PATH] = wxT("");
HRESULT hres = ::SHGetFolderPath(NULL, uPathID, NULL, SHGFP_TYPE_CURRENT, szPath);
return szPath;
}
void CampoSetup::AssociateExtension(const wxFileName& strExeFile, const wxString strExt)
{
// Register icon and application
@ -2001,23 +2013,46 @@ void CampoSetup::AssociateExtension(const wxFileName& strExeFile, const wxString
bool CampoSetup::CreateAutostartMode(const int iSrvAutostartMode, const wxString& strPath)
{
wxFileName strExe(strPath, wxT("lurch.exe"));
strExe.AppendDir("servers");
switch (iSrvAutostartMode)
{
//esecuzione server come servizi (magia!)
case 0:
{
wxString strValue = ReadLocalMachineRegistryKey("SYSTEM\\CurrentControlSet\\Services\\Lerch");
if (strValue.IsEmpty())
//cerca se non esiste per caso gia' da una precedente installazione..
//..non serve piu' a un cazzo ma si e' tenuto come prova in debug di lettura del registry!
wxString strValue = ReadLocalMachineRegistryKey("SYSTEM\\CurrentControlSet\\Services\\Lurch\\Parameters\\Application");
//elimina un eventuale servizio precedente (senno' col cavolo che lo riesce a modificare!)
wxString strRemove = "instsrv Lurch REMOVE";
const long lRemove = wxExecute(strRemove, wxEXEC_SYNC);
//aggiunge la voce ai servizi di windows (dentro strumenti di amministrazione)
wxString strCreateService = "instsrv Lurch ";
strCreateService += wxGetCwd();
strCreateService += "\\srvany.exe";
//esegue il programma di installazione servizi di Windows creando la voce
const long lExec = wxExecute(strCreateService, wxEXEC_SYNC);
if (lExec >= 0)
{
const wxString strCreateService = "./setup/instsrv.exe lerch ./setup/srvany.exe";
wxExecute(strCreateService, wxEXEC_SYNC);
//crea le voci nel registry di windows
WriteLocalMachineRegistryKey("SYSTEM\\CurrentControlSet\\Services\\Lurch\\Parameters\\Application", strExe.GetFullPath());
wxString strExecService = GetFolderPath(CSIDL_SYSTEM);
strExecService += "\\NET START Lurch";
//avvia il servizio
const long lExecLurch = wxExecute(strExecService, wxEXEC_SYNC);
if (lExecLurch < 0)
WarningBox("Impossibile eseguire il servizio del gestore applicazioni.\nLanciarlo manualmente dagli strumenti di amministrazione nel pannello di controllo!");
}
else
WarningBox("Impossibile registrare il servizio per l'esecuzione automatica del gestore applicazioni.\nSelezionare una diversa modalita' di esecuzione!");
}
break;
//link nella cartella esecuzione automatica
case 1:
{
const wxFileName strExe(strPath, wxT("/servers/lerch.exe"));
CreateIcon(CSIDL_COMMON_STARTUP, strPath);
}
break;
@ -2033,17 +2068,15 @@ bool CampoSetup::CreateIcon(unsigned int csidl, const wxFileName& strExeFile) co
{
//csidl = CSIDL_COMMON_DESKTOPDIRECTORY = desktop
//csidl = CSIDL_COMMON_STARTUP = all users esecuzione automatica
TCHAR szDesktopPath[MAX_PATH] = wxT("");
HRESULT hres = ::SHGetFolderPath(NULL, csidl, NULL, SHGFP_TYPE_CURRENT, szDesktopPath);
wxString szDesktopPath = GetFolderPath(csidl);
if (szDesktopPath[0] != '\0')
if (!szDesktopPath.IsEmpty())
{
CoInitialize(NULL);
// Get a pointer to the IShellLink interface.
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
@ -2096,8 +2129,8 @@ void CampoSetup::OnTimer(wxTimerEvent& WXUNUSED(e))
//se sta installando campo in postazione server e deve installare un gestore di servizi
if (uInstallationType == 1)
{
const bool bInstallLerch = pWizard->GetInstUseAuth() | pWizard->GetInstUseDict();
if (bInstallLerch)
const bool bInstallLurch = pWizard->GetInstUseAuth() | pWizard->GetInstUseDict();
if (bInstallLurch)
{
const int iSrvAutostartMode = pWizard->GetSrvAutostartMode();
CreateAutostartMode(iSrvAutostartMode, strDest);