Some more refactoring, removed some thrown Win32 exceptions, replaced them with tracing code
This commit is contained in:
parent
a0048698e7
commit
2367d0e6c0
@ -11,6 +11,11 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
[assembly: AssemblyConfiguration("DEBUG")]
|
||||||
|
#else
|
||||||
|
[assembly: AssemblyConfiguration("RELEASE")]
|
||||||
|
#endif
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
// Version information for an assembly consists of the following four values:
|
||||||
//
|
//
|
||||||
|
@ -35,8 +35,8 @@ Global
|
|||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.Build.0 = Debug|x64
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.Build.0 = Debug|x64
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x86.ActiveCfg = Debug|x86
|
{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}.Debug|x86.Build.0 = Debug|x86
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|Any CPU.Build.0 = Release|x64
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.ActiveCfg = Release|x64
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.ActiveCfg = Release|x64
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.Build.0 = Release|x64
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.Build.0 = Release|x64
|
||||||
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x86.ActiveCfg = Release|x86
|
{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x86.ActiveCfg = Release|x86
|
||||||
@ -47,16 +47,20 @@ Global
|
|||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x64.Build.0 = Debug|x64
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x64.Build.0 = Debug|x64
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x86.ActiveCfg = Debug|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x86.Build.0 = Debug|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Debug|x86.Build.0 = Debug|x86
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|Any CPU.ActiveCfg = Release|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x64.ActiveCfg = Release|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x64.Build.0 = Release|x64
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x86.ActiveCfg = Release|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x86.ActiveCfg = Release|x86
|
||||||
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x86.Build.0 = Release|x86
|
{09BB3AA3-96D3-4BA1-BCB3-4E17067F42B2}.Release|x86.Build.0 = Release|x86
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x64.ActiveCfg = Debug|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x64.Build.0 = Debug|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x64.Build.0 = Debug|x64
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x86.ActiveCfg = Debug|x86
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x86.Build.0 = Debug|x86
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Debug|x86.Build.0 = Debug|x86
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|Any CPU.ActiveCfg = Release|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|Any CPU.Build.0 = Release|x64
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x64.ActiveCfg = Release|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x64.ActiveCfg = Release|x64
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x64.Build.0 = Release|x64
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x64.Build.0 = Release|x64
|
||||||
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x86.ActiveCfg = Release|x86
|
{E8679E1B-8C89-4201-97D5-7E43C5A486C9}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<Window x:Class="PdfScribe.ActivityNotification"
|
<Window x:Class="PdfScribe.ActivityNotification"
|
||||||
|
x:ClassModifier="internal"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="ActivityNotification" Height="300" Width="300"
|
Title="ActivityNotification" Height="300" Width="300"
|
||||||
|
@ -16,9 +16,9 @@ namespace PdfScribe
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ActivityNotification.xaml
|
/// Interaction logic for ActivityNotification.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ActivityNotification : Window
|
internal partial class ActivityNotification : Window
|
||||||
{
|
{
|
||||||
public ActivityNotification()
|
internal ActivityNotification()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ namespace PdfScribe
|
|||||||
/// with a standard error icon, and
|
/// with a standard error icon, and
|
||||||
/// just a Close button
|
/// just a Close button
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="captionText">Text that goes in the window caption</param>
|
/// <param name="captionText">Text that goes in the window's caption</param>
|
||||||
/// <param name="instructionText">Instructional text (Appears next to the icon)</param>
|
/// <param name="instructionText">Instructional text (Appears next to the error icon)</param>
|
||||||
/// <param name="messageText">Smaller message detail text at bottom</param>
|
/// <param name="messageText">Smaller message detail text at bottom</param>
|
||||||
public void ShowSimple(String captionText,
|
public void ShowSimple(String captionText,
|
||||||
String instructionText,
|
String instructionText,
|
||||||
|
@ -8,9 +8,8 @@ using System.Windows;
|
|||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("PdfScribe")]
|
[assembly: AssemblyTitle("PdfScribe")]
|
||||||
[assembly: AssemblyDescription("Postscript output redirector")]
|
[assembly: AssemblyDescription("Postscript printer output redirector")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
@ -77,6 +77,7 @@ namespace PdfScribeCore
|
|||||||
const string NATIVE_COULDNOTENABLE64REDIRECTION = "Could not enable 64-bit file system redirection.";
|
const string NATIVE_COULDNOTENABLE64REDIRECTION = "Could not enable 64-bit file system redirection.";
|
||||||
const string NATIVE_COULDNOTREVERT64REDIRECTION = "Could not revert 64-bit file system redirection.";
|
const string NATIVE_COULDNOTREVERT64REDIRECTION = "Could not revert 64-bit file system redirection.";
|
||||||
|
|
||||||
|
const string INSTALL_ROLLBACK_FAILURE_AT_FUNCTION = "Partial uninstallation failure. Function {0} returned false.";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@ -108,20 +109,38 @@ namespace PdfScribeCore
|
|||||||
#region Port operations
|
#region Port operations
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
public int AddPdfScribePort_Test()
|
public bool AddPdfScribePort_Test()
|
||||||
{
|
{
|
||||||
return AddPdfScribePort();
|
return AddPdfScribePort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private int AddPdfScribePort()
|
private bool AddPdfScribePort()
|
||||||
{
|
{
|
||||||
return DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "AddPort");
|
bool portAdded = false;
|
||||||
|
|
||||||
|
int portAddResult = DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "AddPort");
|
||||||
|
switch (portAddResult)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
portAdded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return portAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeletePdfScribePort()
|
public bool DeletePdfScribePort()
|
||||||
{
|
{
|
||||||
DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "DeletePort");
|
bool portDeleted = false;
|
||||||
|
|
||||||
|
int portDeleteResult = DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "DeletePort");
|
||||||
|
switch (portDeleteResult)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
portDeleted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return portDeleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -130,7 +149,7 @@ namespace PdfScribeCore
|
|||||||
/// <param name="portName"></param>
|
/// <param name="portName"></param>
|
||||||
/// <param name="xcvDataOperation"></param>
|
/// <param name="xcvDataOperation"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <remarks>I can't remember the name of the developer who wrote this code originally,
|
/// <remarks>I can't remember the name/link of the developer who wrote this code originally,
|
||||||
/// so I can't provide a link or credit.</remarks>
|
/// so I can't provide a link or credit.</remarks>
|
||||||
private int DoXcvDataPortOperation(string portName, string portMonitor, string xcvDataOperation)
|
private int DoXcvDataPortOperation(string portName, string portMonitor, string xcvDataOperation)
|
||||||
{
|
{
|
||||||
@ -284,7 +303,16 @@ namespace PdfScribeCore
|
|||||||
{
|
{
|
||||||
bool monitorRemoved = false;
|
bool monitorRemoved = false;
|
||||||
if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, PORTMONITOR)) != 0)
|
if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, PORTMONITOR)) != 0)
|
||||||
|
{
|
||||||
monitorRemoved = true;
|
monitorRemoved = true;
|
||||||
|
// Try to remove the monitor DLL now
|
||||||
|
if (!DeletePdfScribePortMonitorDll())
|
||||||
|
{
|
||||||
|
logEventSource.TraceEvent(TraceEventType.Warning,
|
||||||
|
(int)TraceEventType.Warning,
|
||||||
|
"Could not remove port monitor dll.");
|
||||||
|
}
|
||||||
|
}
|
||||||
return monitorRemoved;
|
return monitorRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,17 +463,12 @@ namespace PdfScribeCore
|
|||||||
driverDirectory,
|
driverDirectory,
|
||||||
1024,
|
1024,
|
||||||
ref dirSizeInBytes))
|
ref dirSizeInBytes))
|
||||||
throw new ApplicationException("Could not retrieve printer driver directory.");
|
throw new DirectoryNotFoundException("Could not retrieve printer driver directory.");
|
||||||
return driverDirectory.ToString();
|
return driverDirectory.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
public bool InstallSoftscanPrinter_Test()
|
delegate bool undoInstall();
|
||||||
{
|
|
||||||
String driverSourceDirectory = @"C:\Code\PdfScribe\Lib\";
|
|
||||||
return InstallPdfScribePrinter(driverSourceDirectory);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installs the port monitor, port,
|
/// Installs the port monitor, port,
|
||||||
@ -460,24 +483,27 @@ namespace PdfScribeCore
|
|||||||
|
|
||||||
bool printerInstalled = false;
|
bool printerInstalled = false;
|
||||||
|
|
||||||
|
|
||||||
|
Stack<undoInstall> undoInstallActions = new Stack<undoInstall>();
|
||||||
|
|
||||||
String driverDirectory = RetrievePrinterDriverDirectory();
|
String driverDirectory = RetrievePrinterDriverDirectory();
|
||||||
|
undoInstallActions.Push(this.RemovePdfScribePortMonitor);
|
||||||
if (AddPdfScribePortMonitor(driverSourceDirectory))
|
if (AddPdfScribePortMonitor(driverSourceDirectory))
|
||||||
{
|
{
|
||||||
|
|
||||||
//if (CopyPrinterDriverFiles(driverSourceDirectory, driverFilesToCopy.Concat(dependentFilesToCopy).ToArray()))
|
|
||||||
if (CopyPrinterDriverFiles(driverSourceDirectory, printerDriverFiles.Concat(printerDriverDependentFiles).ToArray()))
|
if (CopyPrinterDriverFiles(driverSourceDirectory, printerDriverFiles.Concat(printerDriverDependentFiles).ToArray()))
|
||||||
{
|
{
|
||||||
if (AddPdfScribePort() == 0)
|
undoInstallActions.Push(this.RemovePdfScribePortMonitor);
|
||||||
|
if (AddPdfScribePort())
|
||||||
{
|
{
|
||||||
|
undoInstallActions.Push(this.RemovePDFScribePrinterDriver);
|
||||||
if (InstallPdfScribePrinterDriver())
|
if (InstallPdfScribePrinterDriver())
|
||||||
{
|
{
|
||||||
|
undoInstallActions.Push(this.DeletePdfScribePrinter);
|
||||||
if (AddPdfScribePrinter())
|
if (AddPdfScribePrinter())
|
||||||
{
|
{
|
||||||
|
undoInstallActions.Push(this.RemovePdfScribePortConfig);
|
||||||
if (ConfigurePdfScribePort())
|
if (ConfigurePdfScribePort())
|
||||||
{
|
|
||||||
printerInstalled = true;
|
printerInstalled = true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Failed to configure port
|
// Failed to configure port
|
||||||
@ -507,6 +533,31 @@ namespace PdfScribeCore
|
|||||||
{
|
{
|
||||||
//Failed to add port monitor
|
//Failed to add port monitor
|
||||||
}
|
}
|
||||||
|
if (printerInstalled == false)
|
||||||
|
{
|
||||||
|
// Printer installation failed -
|
||||||
|
// undo all the install steps
|
||||||
|
while (undoInstallActions.Count > 0)
|
||||||
|
{
|
||||||
|
undoInstall undoAction = undoInstallActions.Pop();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!undoAction())
|
||||||
|
{
|
||||||
|
this.logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
String.Format(INSTALL_ROLLBACK_FAILURE_AT_FUNCTION, undoAction.Method.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Win32Exception win32Ex)
|
||||||
|
{
|
||||||
|
this.logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
String.Format(INSTALL_ROLLBACK_FAILURE_AT_FUNCTION, undoAction.Method.Name) +
|
||||||
|
String.Format(WIN32ERROR, win32Ex.ErrorCode.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return printerInstalled;
|
return printerInstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,13 +568,18 @@ namespace PdfScribeCore
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool UninstallPdfScribePrinter()
|
public bool UninstallPdfScribePrinter()
|
||||||
{
|
{
|
||||||
bool printerUninstalled = false;
|
bool printerUninstalled = true;
|
||||||
|
|
||||||
DeletePdfScribePrinter();
|
if (!DeletePdfScribePrinter())
|
||||||
RemovePDFScribePrinterDriver();
|
printerUninstalled = false;
|
||||||
DeletePdfScribePort();
|
if (!RemovePDFScribePrinterDriver())
|
||||||
RemovePdfScribePortMonitor();
|
printerUninstalled = false;
|
||||||
RemovePdfScribePortConfig();
|
if (!DeletePdfScribePort())
|
||||||
|
printerUninstalled = false;
|
||||||
|
if (!RemovePdfScribePortMonitor())
|
||||||
|
printerUninstalled = false;
|
||||||
|
if (!RemovePdfScribePortConfig())
|
||||||
|
printerUninstalled = false;
|
||||||
return printerUninstalled;
|
return printerUninstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,18 +716,31 @@ namespace PdfScribeCore
|
|||||||
printerDriverInstalled = NativeMethods.AddPrinterDriver(null, 6, ref printerDriverInfo);
|
printerDriverInstalled = NativeMethods.AddPrinterDriver(null, 6, ref printerDriverInfo);
|
||||||
if (printerDriverInstalled == false)
|
if (printerDriverInstalled == false)
|
||||||
{
|
{
|
||||||
int lastWinError = Marshal.GetLastWin32Error();
|
//int lastWinError = Marshal.GetLastWin32Error();
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add printer PDF Scribe printer driver.");
|
//throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add printer PDF Scribe printer driver.");
|
||||||
|
logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
"Could add PDF Scribe printer driver." +
|
||||||
|
String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
|
||||||
}
|
}
|
||||||
return printerDriverInstalled;
|
return printerDriverInstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public bool RemovePDFScribePrinterDriver()
|
public bool RemovePDFScribePrinterDriver()
|
||||||
{
|
{
|
||||||
bool driverRemoved = NativeMethods.DeletePrinterDriverEx(null, ENVIRONMENT_64, DRIVERNAME, DPD_DELETE_UNUSED_FILES, 3);
|
bool driverRemoved = NativeMethods.DeletePrinterDriverEx(null, ENVIRONMENT_64, DRIVERNAME, DPD_DELETE_UNUSED_FILES, 3);
|
||||||
if (!driverRemoved)
|
if (!driverRemoved)
|
||||||
{
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not remove PDF Scribe printer driver");
|
//throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not remove PDF Scribe printer driver");
|
||||||
|
logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
"Could not remove PDF Scribe printer driver." +
|
||||||
|
String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
|
||||||
}
|
}
|
||||||
return driverRemoved;
|
return driverRemoved;
|
||||||
}
|
}
|
||||||
@ -690,16 +759,20 @@ namespace PdfScribeCore
|
|||||||
pdfScribePrinter.pDatatype = "RAW";
|
pdfScribePrinter.pDatatype = "RAW";
|
||||||
pdfScribePrinter.Attributes = 0x00000002;
|
pdfScribePrinter.Attributes = 0x00000002;
|
||||||
|
|
||||||
int softScanPrinterHandle = NativeMethods.AddPrinter(null, 2, ref pdfScribePrinter);
|
int pdfScribePrinterHandle = NativeMethods.AddPrinter(null, 2, ref pdfScribePrinter);
|
||||||
if (softScanPrinterHandle != 0)
|
if (pdfScribePrinterHandle != 0)
|
||||||
{
|
{
|
||||||
// Added ok
|
// Added ok
|
||||||
int closeCode = NativeMethods.ClosePrinter((IntPtr)softScanPrinterHandle);
|
int closeCode = NativeMethods.ClosePrinter((IntPtr)pdfScribePrinterHandle);
|
||||||
printerAdded = true;
|
printerAdded = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add PDF Scribe virtual printer.");
|
//throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add PDF Scribe virtual printer.");
|
||||||
|
logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
"Could not add PDF Scribe virtual printer." +
|
||||||
|
String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
|
||||||
}
|
}
|
||||||
return printerAdded;
|
return printerAdded;
|
||||||
}
|
}
|
||||||
@ -723,7 +796,10 @@ namespace PdfScribeCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// log error
|
logEventSource.TraceEvent(TraceEventType.Error,
|
||||||
|
(int)TraceEventType.Error,
|
||||||
|
"Could not delete PDF Scribe virtual printer." +
|
||||||
|
String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -758,9 +834,9 @@ namespace PdfScribeCore
|
|||||||
portConfiguration.SetValue("Description", "PDF Scribe", RegistryValueKind.String);
|
portConfiguration.SetValue("Description", "PDF Scribe", RegistryValueKind.String);
|
||||||
portConfiguration.SetValue("Command", "", RegistryValueKind.String);
|
portConfiguration.SetValue("Command", "", RegistryValueKind.String);
|
||||||
portConfiguration.SetValue("Arguments", "", RegistryValueKind.String);
|
portConfiguration.SetValue("Arguments", "", RegistryValueKind.String);
|
||||||
portConfiguration.SetValue("Printer", "", RegistryValueKind.String);
|
portConfiguration.SetValue("Printer", PRINTERNAME, RegistryValueKind.String);
|
||||||
portConfiguration.SetValue("Output", 0, RegistryValueKind.DWord);
|
portConfiguration.SetValue("Output", 0, RegistryValueKind.DWord);
|
||||||
portConfiguration.SetValue("ShowWindow", 0, RegistryValueKind.DWord);
|
portConfiguration.SetValue("ShowWindow", 2, RegistryValueKind.DWord);
|
||||||
portConfiguration.SetValue("RunUser", 1, RegistryValueKind.DWord);
|
portConfiguration.SetValue("RunUser", 1, RegistryValueKind.DWord);
|
||||||
portConfiguration.SetValue("Delay", 300, RegistryValueKind.DWord);
|
portConfiguration.SetValue("Delay", 300, RegistryValueKind.DWord);
|
||||||
portConfiguration.SetValue("LogFileUse", 0, RegistryValueKind.DWord);
|
portConfiguration.SetValue("LogFileUse", 0, RegistryValueKind.DWord);
|
||||||
|
@ -7,7 +7,6 @@ using System.Runtime.InteropServices;
|
|||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("PdfScribeCore")]
|
[assembly: AssemblyTitle("PdfScribeCore")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<supportedRuntime version="v4.0" />
|
<supportedRuntime version="v4.0" />
|
||||||
<supportedRuntime version="v2.0.50727"/>
|
<!-- <supportedRuntime version="v2.0.50727"/> -->
|
||||||
|
|
||||||
</startup>
|
</startup>
|
||||||
|
|
||||||
|
@ -51,6 +51,26 @@
|
|||||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<ErrorReportUrlHistory />
|
<ErrorReportUrlHistory />
|
||||||
<FallbackCulture>en-US</FallbackCulture>
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
<ProjectView>ShowAllFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ReferencePath>
|
<ReferencePath>
|
||||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
//[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
@ -37,7 +37,7 @@ namespace PdfScribeUnitTests
|
|||||||
public void Test_InstallPdfScribePrinter()
|
public void Test_InstallPdfScribePrinter()
|
||||||
{
|
{
|
||||||
var scribeInstaller = new PdfScribeInstaller();
|
var scribeInstaller = new PdfScribeInstaller();
|
||||||
scribeInstaller.InstallSoftscanPrinter_Test();
|
scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\");
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Test]
|
//[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user