Revision: 73
http://svn.sourceforge.net/nmailserver/?rev=73&view=rev
Author: tmyroadctfig
Date: 2006-11-06 06:05:36 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
Work on post install.
Modified Paths:
--------------
NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj
NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs
NMail/branches/luke-dev/NMail.PostInstall/Program.cs
Removed Paths:
-------------
NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs
Deleted: NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs 2006-10-31 12:29:59 UTC (rev 72)
+++ NMail/branches/luke-dev/NMail.PostInstall/CustomAction.cs 2006-11-06 14:05:36 UTC (rev 73)
@@ -1,35 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Text;
-using System.Windows.Forms;
-
-using Microsoft.Win32;
-
-using NMail.SmtpService;
-
-namespace NMail.PostInstall {
-
- public class CustomAction {
-
-
- }
-}
Modified: NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj 2006-10-31 12:29:59 UTC (rev 72)
+++ NMail/branches/luke-dev/NMail.PostInstall/NMail.PostInstall.csproj 2006-11-06 14:05:36 UTC (rev 73)
@@ -36,7 +36,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="CustomAction.cs" />
<Compile Include="PostInstallForm.cs">
<SubType>Form</SubType>
</Compile>
Modified: NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs 2006-10-31 12:29:59 UTC (rev 72)
+++ NMail/branches/luke-dev/NMail.PostInstall/PostInstallForm.cs 2006-11-06 14:05:36 UTC (rev 73)
@@ -21,6 +21,7 @@
using System.Data;
using System.Diagnostics;
using System.Drawing;
+using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
@@ -31,10 +32,11 @@
namespace NMail.PostInstall {
public partial class PostInstallForm : Form {
- public PostInstallForm() {
+
+ public PostInstallForm(string[] args) {
InitializeComponent();
- if (NMailInstalled()) {
+ if (args.Length > 1 && args[1].Contains("/u")) {
this.messageLbl.Text = "Performing final uninstall steps.";
ThreadPool.QueueUserWorkItem(new WaitCallback(Uninstall), null);
} else {
@@ -68,92 +70,53 @@
}
private bool NMailInstalled() {
- RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", false);
-
- // Check for the NMail key
- RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, false);
-
- if (nmailKey == null) {
- return false;
- }
-
- // Check for the NMail Server key
- RegistryKey nmailSeverKey = nmailKey.OpenSubKey(NMailServerKey, false);
-
- bool installed = (nmailSeverKey != null);
-
- nmailKey.Close();
- if (nmailSeverKey != null) {
- nmailSeverKey.Close();
- }
-
- return installed;
+ return (GetInstallDirectory() != null);
}
+
+ /// <summary>
+ /// Gets the NMail install directory from the registery.
+ /// </summary>
+ /// <returns>The install location or null if an error occurs.</returns>
+ public string GetInstallDirectory() {
+ string installDirectory = null;
+ RegistryKey nmailServerKey = Registry.LocalMachine.OpenSubKey(@"Software\NMail\NMail Server 1.0", false);
- private void SetupNMailRegistryKeys() {
- RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
+ if (nmailServerKey != null) {
+ installDirectory = nmailServerKey.GetValue("InstallDirectory") as string;
- // Create for the NMail key
- RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, true);
-
- if (nmailKey == null) {
- nmailKey = softwareKey.CreateSubKey(NMailKey);
+ nmailServerKey.Close();
}
- // Create for the NMail Server key
- RegistryKey nmailSeverKey = nmailKey.OpenSubKey(NMailServerKey, false);
-
- if (nmailSeverKey == null) {
- nmailSeverKey = nmailKey.CreateSubKey(NMailServerKey);
- }
-
- nmailKey.Close();
- nmailSeverKey.Close();
+ return installDirectory;
}
- private void DeleteNMailRegistryKeys() {
- RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
-
- // Get the key for the NMail
- RegistryKey nmailKey = softwareKey.OpenSubKey(NMailKey, true);
-
- if (nmailKey != null) {
- nmailKey.DeleteSubKeyTree(NMailServerKey);
- nmailKey.Close();
- }
-
- // Try to delete the top level key (will fail if other sub-keys are present)
- softwareKey.DeleteSubKey(NMailKey, false);
- }
-
public void Install(object unused) {
try {
DeleteSmtpServiceCounters();
- DeleteNMailRegistryKeys();
-
- SetupNMailRegistryKeys();
-
SetupSmtpServiceCounters();
- Application.Exit();
+ ProcessStartInfo psi = new ProcessStartInfo();
+ psi.WorkingDirectory = GetInstallDirectory();
+ psi.FileName = psi.WorkingDirectory + Path.DirectorySeparatorChar + "NMail.SetupWizard.exe";
+ Process.Start(psi);
} catch (Exception e) {
ShowErrorBox("Error performing install: " + e.Message);
}
+
+ Application.Exit();
}
public void Uninstall(object unused) {
try {
DeleteSmtpServiceCounters();
- DeleteNMailRegistryKeys();
-
- Application.Exit();
-
} catch (Exception e) {
ShowErrorBox("Error performing uninstall: " + e.Message);
}
+
+ Application.Exit();
}
private void ShowErrorBox(object o) {
@@ -170,9 +133,5 @@
protected override void OnClosing(CancelEventArgs e) {
e.Cancel = true;
}
-
- public const string NMailKey = "NMail";
-
- public const string NMailServerKey = "NMail Server 1.0";
}
}
\ No newline at end of file
Modified: NMail/branches/luke-dev/NMail.PostInstall/Program.cs
===================================================================
--- NMail/branches/luke-dev/NMail.PostInstall/Program.cs 2006-10-31 12:29:59 UTC (rev 72)
+++ NMail/branches/luke-dev/NMail.PostInstall/Program.cs 2006-11-06 14:05:36 UTC (rev 73)
@@ -25,10 +25,10 @@
/// The main entry point for the application.
/// </summary>
[STAThread]
- static void Main() {
+ static void Main(string[] args) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new PostInstallForm());
+ Application.Run(new PostInstallForm(args));
}
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|