more refactoring

This commit is contained in:
S T Chan 2013-12-18 23:58:43 -05:00
parent ca5fe19474
commit 5a00b62203
2 changed files with 18 additions and 10 deletions

View File

@ -86,15 +86,22 @@ namespace PdfScribeCore
private int AddPdfScribePort()
{
return DoXcvDataPortOperation(PORTNAME, "AddPort");
return DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "AddPort");
}
public void DeletePdfScribePort(string portName)
public void DeletePdfScribePort()
{
DoXcvDataPortOperation(portName, "DeletePort");
DoXcvDataPortOperation(PORTNAME, PORTMONITOR, "DeletePort");
}
private int DoXcvDataPortOperation(string portName, string xcvDataOperation)
/// <summary>
///
/// </summary>
/// <param name="portName"></param>
/// <param name="xcvDataOperation"></param>
/// <returns></returns>
/// <remarks>I can't remember the name of the coder who wrote this code originally</remarks>
private int DoXcvDataPortOperation(string portName, string portMonitor, string xcvDataOperation)
{
int win32ErrorCode;
@ -107,7 +114,7 @@ namespace PdfScribeCore
IntPtr hPrinter = IntPtr.Zero;
if (NativeMethods.OpenPrinter(",XcvMonitor " + PORTMONITOR, ref hPrinter, def) != 0)
if (NativeMethods.OpenPrinter(",XcvMonitor " + portMonitor, ref hPrinter, def) != 0)
{
if (!portName.EndsWith("\0"))
portName += "\0"; // Must be a null terminated string
@ -467,7 +474,7 @@ namespace PdfScribeCore
DeletePdfScribePrinter();
RemovePDFScribePrinterDriver();
DeletePdfScribePort(PORTNAME);
DeletePdfScribePort();
RemovePdfScribePortMonitor();
RemovePdfScribePortConfig();
return printerUninstalled;
@ -669,11 +676,12 @@ namespace PdfScribeCore
bool registryChangesMade = false;
// Add all the registry info
// for the port and monitor
RegistryKey portConfiguration = Registry.LocalMachine.CreateSubKey("SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors\\" +
PORTMONITOR +
"\\Ports\\" + PORTNAME);
RegistryKey portConfiguration;
try
{
portConfiguration = Registry.LocalMachine.CreateSubKey("SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors\\" +
PORTMONITOR +
"\\Ports\\" + PORTNAME);
portConfiguration.SetValue("Description", "PDF Scribe", RegistryValueKind.String);
portConfiguration.SetValue("Command", "", RegistryValueKind.String);
portConfiguration.SetValue("Arguments", "", RegistryValueKind.String);

View File

@ -23,7 +23,7 @@ namespace PdfScribeUnitTests
public void Test_DeletePdfScribePort()
{
var scribeInstaller = new PdfScribeInstaller();
scribeInstaller.DeletePdfScribePort("PDFSCRIBE:");
scribeInstaller.DeletePdfScribePort();
}
//[Test]