diff --git a/PdfScribe.sln b/PdfScribe.sln
index 006861b..553b26b 100644
--- a/PdfScribe.sln
+++ b/PdfScribe.sln
@@ -13,8 +13,8 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.ActiveCfg = Debug|x64
- {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.Build.0 = Debug|x64
+ {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.Build.0 = Debug|Any CPU
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x86.ActiveCfg = Debug|x86
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x86.Build.0 = Debug|x86
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.ActiveCfg = Release|x64
diff --git a/PdfScribe/NativeMethods.cs b/PdfScribe/NativeMethods.cs
index 852acef..1668f64 100644
--- a/PdfScribe/NativeMethods.cs
+++ b/PdfScribe/NativeMethods.cs
@@ -154,28 +154,10 @@ namespace PdfScribe
int bufferSize,
ref int Bytes);
- public static IntPtr DisableWow64Redirection()
- {
- IntPtr oldValue = IntPtr.Zero;
- if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
- if (!NativeMethods.Wow64DisableWow64FsRedirection(ref oldValue))
- throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not disable Wow64 file system redirection.");
- return oldValue;
- }
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
- public static void RevertWow64Redirection(IntPtr oldValue)
- {
- if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
- {
- if (!NativeMethods.Wow64RevertWow64FsRedirection(oldValue))
- {
- throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not reenable Wow64 file system redirection.");
- }
- }
- }
}
}
diff --git a/PdfScribe/PdfScribe.csproj b/PdfScribe/PdfScribe.csproj
index b5cc212..0483a1d 100644
--- a/PdfScribe/PdfScribe.csproj
+++ b/PdfScribe/PdfScribe.csproj
@@ -91,7 +91,6 @@
-
diff --git a/PdfScribe/PdfScribeInstaller.cs b/PdfScribe/PdfScribeInstaller.cs
index c3693e2..9ba03a1 100644
--- a/PdfScribe/PdfScribeInstaller.cs
+++ b/PdfScribe/PdfScribeInstaller.cs
@@ -33,6 +33,7 @@ namespace PdfScribe
#region Port operations
+
private int AddPdfScribePort(string portName)
{
return DoXcvDataPortOperation(portName, "AddPort");
@@ -89,9 +90,12 @@ namespace PdfScribe
#region Port Monitor
- public bool AddPdfScribePortMonitor(String monitorName,
- String monitorFile,
- String monitorPath)
+ ///
+ /// Adds the PDF Scribe port monitor
+ ///
+ /// Directory where the uninstalled monitor dll is located
+ /// true if the monitor is installed, false if install failed
+ public bool AddPdfScribePortMonitor(String monitorFilePath)
{
bool monitorAdded = false;
@@ -99,20 +103,20 @@ namespace PdfScribe
try
{
- oldRedirectValue = NativeMethods.DisableWow64Redirection();
- if (!DoesMonitorExist(monitorName))
+ oldRedirectValue = DisableWow64Redirection();
+ if (!DoesMonitorExist(PORTMONITOR))
{
// Copy the monitor DLL to
// the system directory
- String fileSourcePath = Path.Combine(monitorPath, monitorFile);
- String fileDestinationPath = Path.Combine(Environment.SystemDirectory, monitorFile);
+ String fileSourcePath = Path.Combine(monitorFilePath, MONITORDLL);
+ String fileDestinationPath = Path.Combine(Environment.SystemDirectory, MONITORDLL);
File.Copy(fileSourcePath, fileDestinationPath, true);
MONITOR_INFO_2 newMonitor = new MONITOR_INFO_2();
- newMonitor.pName = monitorName;
+ newMonitor.pName = PORTMONITOR;
newMonitor.pEnvironment = ENVIRONMENT_64;
- newMonitor.pDLLName = monitorFile;
+ newMonitor.pDLLName = MONITORDLL;
if (!AddPortMonitor(newMonitor))
- throw new Win32Exception(Marshal.GetLastWin32Error(), String.Format("Could not add port monitor {0}", monitorName));
+ throw new Win32Exception(Marshal.GetLastWin32Error(), String.Format("Could not add port monitor {0}", PORTMONITOR));
else
monitorAdded = true;
}
@@ -120,25 +124,54 @@ namespace PdfScribe
}
finally
{
- /*
- // Remove the monitor dll if copied
- try
- {
- File.Delete(Path.Combine(Environment.SystemDirectory, monitorFile));
- }
- catch { }
- */
- if (oldRedirectValue != IntPtr.Zero) NativeMethods.RevertWow64Redirection(oldRedirectValue);
+ if (oldRedirectValue != IntPtr.Zero) RevertWow64Redirection(oldRedirectValue);
}
return monitorAdded;
}
- public bool RemoveSoftscanPortMonitor(String monitorName)
+
+ ///
+ /// Disables WOW64 system directory file redirection
+ /// if the current process is both
+ /// 32-bit, and running on a 64-bit OS
+ ///
+ /// A Handle, which should be retained to reenable redirection
+ private IntPtr DisableWow64Redirection()
+ {
+ IntPtr oldValue = IntPtr.Zero;
+ if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
+ if (!NativeMethods.Wow64DisableWow64FsRedirection(ref oldValue))
+ throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not disable Wow64 file system redirection.");
+ return oldValue;
+ }
+
+ ///
+ /// Reenables WOW64 system directory file redirection
+ /// if the current process is both
+ /// 32-bit, and running on a 64-bit OS
+ ///
+ /// A Handle value - should be retained from call to
+ private void RevertWow64Redirection(IntPtr oldValue)
+ {
+ if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
+ {
+ if (!NativeMethods.Wow64RevertWow64FsRedirection(oldValue))
+ {
+ throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not reenable Wow64 file system redirection.");
+ }
+ }
+ }
+
+ ///
+ /// Removes the PDF Scribe port monitor
+ ///
+ /// true if monitor successfully removed, false if removal failed
+ public bool RemovePdfScribePortMonitor()
{
bool monitorRemoved = false;
- if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, monitorName)) != 0)
+ if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, PORTMONITOR)) != 0)
monitorRemoved = true;
return monitorRemoved;
}
@@ -236,17 +269,24 @@ namespace PdfScribe
#if DEBUG
public bool InstallSoftscanPrinter_Test()
{
- String printerName = PRINTERNAME;
String driverSourceDirectory = @"C:\Code\OaisisRedmonInstaller\Lib\";
String[] driverFilesToCopy = new String[] { DRIVERFILE, DRIVERDATAFILE, DRIVERHELPFILE, DRIVERUIFILE };
String[] dependentFilesToCopy = new String[] { "PSCRIPT.NTF" };
- return InstallPdfScribePrinter(printerName, driverSourceDirectory, driverFilesToCopy, dependentFilesToCopy);
+ return InstallPdfScribePrinter(driverSourceDirectory, driverFilesToCopy, dependentFilesToCopy);
}
#endif
- public bool InstallPdfScribePrinter(String printerName,
- String driverSourceDirectory,
- String[] driverFilesToCopy,
- String[] dependentFilesToCopy)
+
+ ///
+ /// Installs the port monitor, port,
+ /// printer drivers, and PDF Scribe virtual printer
+ ///
+ /// Directory where the uninstalled printer driver files are located
+ /// An array containing the printer driver's filenames
+ /// An array containing dependent filenames
+ /// true if printer installed, false if failed
+ public bool InstallPdfScribePrinter(String driverSourceDirectory,
+ String[] driverFilesToCopy,
+ String[] dependentFilesToCopy)
{
bool printerInstalled = false;
@@ -255,7 +295,7 @@ namespace PdfScribe
{
if (CopyPrinterDriverFiles(driverSourceDirectory, driverFilesToCopy.Concat(dependentFilesToCopy).ToArray()))
{
- if (AddPdfScribePortMonitor(PORTMONITOR, MONITORDLL, driverSourceDirectory))
+ if (AddPdfScribePortMonitor(driverSourceDirectory))
{
if (InstallPrinterDriver(driverDirectory, dependentFilesToCopy))
{