Implemented VirtualPrinterDriver project
This commit is contained in:
parent
f29c84821b
commit
5c87967c3f
125 changed files with 8191 additions and 0 deletions
15
Installer/VirtualPrinter.SetupDriver/Defaults.cs
Normal file
15
Installer/VirtualPrinter.SetupDriver/Defaults.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
namespace VirtualPrinter.SetupDriver
|
||||
{
|
||||
public static class Defaults
|
||||
{
|
||||
/// <summary>
|
||||
/// The name that appears in the Windows "Printer & Scanner" menu.
|
||||
/// </summary>
|
||||
public const string PrinterName = "AMAGNO";
|
||||
|
||||
/// <summary>
|
||||
/// The printer port.
|
||||
/// </summary>
|
||||
public const string PrinterPort = "IP_VIRT_PRINTER";
|
||||
}
|
||||
}
|
||||
125
Installer/VirtualPrinter.SetupDriver/Program.cs
Normal file
125
Installer/VirtualPrinter.SetupDriver/Program.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using VirtualPrinter.Logging;
|
||||
using VirtualPrinter.Utils;
|
||||
|
||||
using static VirtualPrinter.SetupDriver.Windows;
|
||||
using static VirtualPrinter.SetupDriver.Defaults;
|
||||
|
||||
namespace VirtualPrinter.SetupDriver
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private const string InstallCmd = "install";
|
||||
private const string TestCmd = "test";
|
||||
private const string ConfigCmd = "config";
|
||||
private const string UninstallCmd = "uninstall";
|
||||
|
||||
private static readonly IVirtualPrinterLogger<Program> Logger = new VirtualPrinterLogger<Program>();
|
||||
|
||||
private static void Main([CanBeNull]string[] args)
|
||||
{
|
||||
if (args == null || args.Length < 1)
|
||||
{
|
||||
NotUseful();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case InstallCmd:
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
NotUseful();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[1].ToLower())
|
||||
{
|
||||
case "xps":
|
||||
try
|
||||
{
|
||||
AddPrinterPort(PrinterPort, "127.0.0.1", 9101);
|
||||
var isWin7 = Environment.OSVersion.VersionString.Contains("NT 6.1.");
|
||||
AddPrinter(PrinterName, "Microsoft XPS Document Writer" + (isWin7 ? string.Empty : " v4"), PrinterPort);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Failed to add xps printer.");
|
||||
}
|
||||
break;
|
||||
case "ps":
|
||||
try
|
||||
{
|
||||
AddPrinterPort(PrinterPort, "127.0.0.1", 9101);
|
||||
new RegistryRepository().TryGetGhostscriptPath(out var ghostScriptPath);
|
||||
if (ghostScriptPath == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ghostScriptPath), "Ghostscript path could not be found.");
|
||||
}
|
||||
|
||||
AddPrinter(PrinterName, "Ghostscript PDF", PrinterPort, Path.Combine(ghostScriptPath, @"lib\ghostpdf.inf"));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Failed to add ps printer.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NotUseful();
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TestCmd: {
|
||||
TestPrinter(PrinterName);
|
||||
break;
|
||||
}
|
||||
case ConfigCmd: {
|
||||
try
|
||||
{
|
||||
ConfigPrinter(PrinterName);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Failed to configurate printer {printerName}.", PrinterName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UninstallCmd: {
|
||||
try
|
||||
{
|
||||
DelPrinter(PrinterName);
|
||||
DelPrinterPort(PrinterPort);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Failed to uninstall {printerName} on port {printerPort}.", PrinterName, PrinterPort);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
NotUseful();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void NotUseful()
|
||||
{
|
||||
var exception = new ArgumentNullException($"Use '{InstallCmd} [PS|XPS]', '{TestCmd}' or '{UninstallCmd}'!");
|
||||
LogError(exception, "Failed to handle the arguments.");
|
||||
throw exception;
|
||||
}
|
||||
|
||||
private static void LogError(Exception exception, string message, params object[] args)
|
||||
{
|
||||
Logger.Error(exception, message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("VirtualPrinter.SetupDriver")]
|
||||
[assembly: AssemblyDescription("The setup for the virtual printer driver")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("12402f90-a2ae-4549-9142-f90650e2082a")]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly: InternalsVisibleTo("properties")]
|
||||
84
Installer/VirtualPrinter.SetupDriver/Shell.cs
Normal file
84
Installer/VirtualPrinter.SetupDriver/Shell.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using VirtualPrinter.Logging;
|
||||
|
||||
namespace VirtualPrinter.SetupDriver
|
||||
{
|
||||
internal class Shell
|
||||
{
|
||||
private static readonly string WinFolder;
|
||||
|
||||
private static readonly IVirtualPrinterLogger<Shell> Logger = new VirtualPrinterLogger<Shell>();
|
||||
|
||||
static Shell()
|
||||
{
|
||||
WinFolder = Environment.GetEnvironmentVariable("windir") ?? @"C:\Windows";
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
internal static string GetPrintInf()
|
||||
{
|
||||
try
|
||||
{
|
||||
var winFolder = Environment.GetEnvironmentVariable("windir") ?? @"C:\Windows";
|
||||
return Path.Combine(winFolder, "inf", "ntprint.inf");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Cannot get PrintInf");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
internal static string GetPrintVbs()
|
||||
{
|
||||
try
|
||||
{
|
||||
var printScripts = Path.Combine(WinFolder, "System32", "Printing_Admin_Scripts");
|
||||
return Directory.GetFiles(printScripts, "*port.vbs", SearchOption.AllDirectories).First();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Cannot get PrintVbs");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Execute([NotNull]string exe, [NotNull]string args)
|
||||
{
|
||||
if (exe == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(exe));
|
||||
}
|
||||
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(args));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine(exe + " " + args);
|
||||
using(var proc = Process.Start(exe, args))
|
||||
{
|
||||
proc?.WaitForExit();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogError(exception, "Cannot execute {exe} with the following args: {args}", exe, args);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogError(Exception exception, string message, params object[] args)
|
||||
{
|
||||
Logger.Error(exception, message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{12402F90-A2AE-4549-9142-F90650E2082A}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>VirtualPrinter.SetupDriver</RootNamespace>
|
||||
<AssemblyName>setupdrv</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Files\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>VirtualPrinter.SetupDriver.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Defaults.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Shell.cs" />
|
||||
<Compile Include="Windows.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\VirtualPrinter.Logging\VirtualPrinter.Logging.csproj">
|
||||
<Project>{aa25364d-22d5-44b0-86a5-6fb14c686308}</Project>
|
||||
<Name>VirtualPrinter.Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\VirtualPrinter.Utils\VirtualPrinter.Utils.csproj">
|
||||
<Project>{cd1c8e9d-5335-41ac-b0c0-88fd7c7c55f3}</Project>
|
||||
<Name>VirtualPrinter.Utils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
93
Installer/VirtualPrinter.SetupDriver/Windows.cs
Normal file
93
Installer/VirtualPrinter.SetupDriver/Windows.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace VirtualPrinter.SetupDriver
|
||||
{
|
||||
internal static class Windows
|
||||
{
|
||||
public static void AddPrinter([NotNull]string name, [NotNull]string model, [NotNull]string port, [CanBeNull]string driver = null)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (port == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(port));
|
||||
}
|
||||
|
||||
driver = driver ?? Shell.GetPrintInf();
|
||||
var args = $@"printui.dll,PrintUIEntry /if /b ""{name}"" /f ""{driver}"" /r ""{port}"" /m ""{model}"" /u";
|
||||
Shell.Execute("rundll32", args);
|
||||
}
|
||||
|
||||
public static void TestPrinter([NotNull]string name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var args = $@"printui.dll,PrintUIEntry /k /n ""{name}""";
|
||||
Shell.Execute("rundll32", args);
|
||||
}
|
||||
|
||||
public static void ConfigPrinter([NotNull]string name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var args = $@"printui.dll,PrintUIEntry /e /n ""{name}""";
|
||||
Shell.Execute("rundll32", args);
|
||||
}
|
||||
|
||||
public static void DelPrinter([NotNull]string name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var args = $@"printui.dll,PrintUIEntry /dl /n ""{name}""";
|
||||
Shell.Execute("rundll32", args);
|
||||
}
|
||||
|
||||
public static void AddPrinterPort([NotNull]string name, [NotNull]string ip, int port, [CanBeNull]string vbs = null)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (ip == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ip));
|
||||
}
|
||||
|
||||
vbs = vbs ?? Shell.GetPrintVbs();
|
||||
var args = $@"""{vbs}"" -a -r {name} -h {ip} -o raw -n {port}";
|
||||
Shell.Execute("cscript", args);
|
||||
}
|
||||
|
||||
public static void DelPrinterPort([NotNull]string name, [CanBeNull]string vbs = null)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
vbs = vbs ?? Shell.GetPrintVbs();
|
||||
var args = $@"""{vbs}"" -d -r {name}";
|
||||
Shell.Execute("cscript", args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("VirtualPrinter.WixSharpInstaller")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 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
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a668846e-54c7-483d-9cf7-48f77ea398ca")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
171
Installer/VirtualPrinter.WixSharpInstaller/Script.cs
Normal file
171
Installer/VirtualPrinter.WixSharpInstaller/Script.cs
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
// ReSharper disable once RedundantUsingDirective
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using VirtualPrinter.Utils;
|
||||
|
||||
using WixSharp;
|
||||
|
||||
using Action = WixSharp.Action;
|
||||
using File = WixSharp.File;
|
||||
using Files = VirtualPrinter.Utils.Files;
|
||||
using RegistryHive = WixSharp.RegistryHive;
|
||||
|
||||
namespace VirtualPrinter.WixSharpInstaller
|
||||
{
|
||||
public class Script
|
||||
{
|
||||
private static string _filesDir;
|
||||
const string SetupDriverId = "setupdrv_exe";
|
||||
|
||||
public static void Main([NotNull]string[] args)
|
||||
{
|
||||
var workingDir = "";
|
||||
if (args.Length > 0)
|
||||
{
|
||||
foreach(var cmd in args)
|
||||
{
|
||||
if (cmd.Contains(@"/p:"))
|
||||
{
|
||||
workingDir = cmd.Remove(0, 3);
|
||||
Console.WriteLine(workingDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (workingDir.IsNullOrEmpty())
|
||||
{
|
||||
throw new ArgumentException("Argument for working directory (/p) not set.");
|
||||
}
|
||||
|
||||
_filesDir = Path.Combine(workingDir, Files.FILES);
|
||||
var feature = new Feature("VPD");
|
||||
var printerServiceFile = new File(feature, Path.Combine(_filesDir, Files.PRINTER_SERVICE_EXE))
|
||||
{
|
||||
ServiceInstaller = new ServiceInstaller
|
||||
{
|
||||
Name = "VirtualPrinterService",
|
||||
StartOn = SvcEvent.Install_Wait,
|
||||
StopOn = SvcEvent.InstallUninstall_Wait,
|
||||
RemoveOn = SvcEvent.Uninstall_Wait,
|
||||
ErrorControl = SvcErrorControl.normal,
|
||||
ConfigureServiceTrigger = ConfigureServiceTrigger.None
|
||||
}
|
||||
};
|
||||
|
||||
var project = new ManagedProject("VPDInstaller")
|
||||
{
|
||||
Name = "Virtual Printer Driver",
|
||||
GUID = new Guid("8712D2CD-A9F6-456F-99C8-92C2BB070596"),
|
||||
UpgradeCode = new Guid("0B37A935-EDEC-4ACA-9307-6D8299496C1D"),
|
||||
UI = WUI.WixUI_InstallDir,
|
||||
Version = Version.Parse(FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion),
|
||||
LicenceFile = Files.LICENCE_FILE,
|
||||
Dirs = CreateProjectDirs(feature, printerServiceFile),
|
||||
Actions = CreateActions(),
|
||||
RegValues = CreateRegValues(feature).ToArray(),
|
||||
InstallPrivileges = InstallPrivileges.elevated
|
||||
};
|
||||
|
||||
project.BuildMsi();
|
||||
}
|
||||
|
||||
[NotNull, ItemNotNull]
|
||||
private static Dir[] CreateProjectDirs
|
||||
(
|
||||
Feature feature,
|
||||
File printerServiceFile
|
||||
)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new Dir
|
||||
(
|
||||
@"%ProgramFiles%\MyPrinterDriver\",
|
||||
new DirFiles(feature, _filesDir + @"\*", s => !s.EndsWith(".exe")),
|
||||
new File(new Id(SetupDriverId), feature, Path.Combine(_filesDir, Files.SETUP_DRIVER_EXE)),
|
||||
new File(feature, Path.Combine(_filesDir, Files.DILIVERY_EXE)),
|
||||
new File(feature, Path.Combine(_filesDir, Files.AGENT_PROGRESS_EXE)),
|
||||
printerServiceFile
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
[NotNull, ItemNotNull]
|
||||
private static Action[] CreateActions()
|
||||
{
|
||||
return new Action[]
|
||||
{
|
||||
new InstalledFileAction(SetupDriverId, "install ps", Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed),
|
||||
new InstalledFileAction(SetupDriverId, "uninstall", Return.check, When.Before, Step.RemoveFiles, Condition.BeingUninstalled)
|
||||
};
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
private static IEnumerable<RegValue> CreateRegValues(Feature feature)
|
||||
{
|
||||
var converterKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.CONVERTER_KEY}";
|
||||
|
||||
var regValues = new List<RegValue>();
|
||||
regValues.AddRange(CreateLocalMachineValues(feature, converterKey));
|
||||
regValues.AddRange(CreateCurrentUserValues(feature, converterKey));
|
||||
|
||||
return regValues;
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
private static IEnumerable<RegValue> CreateLocalMachineValues(Feature feature, string converterKey)
|
||||
{
|
||||
var postConverterKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.POSTCONVERTER_KEY}";
|
||||
var preConverterKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.PRECONVERTER_KEY}";
|
||||
var converterPdfKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.CONVERTER_PDF_KEY}";
|
||||
var converterTiffKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.CONVERTER_TIFF_KEY}";
|
||||
var registryHive = RegistryHive.LocalMachine;
|
||||
|
||||
return new List<RegValue>
|
||||
{
|
||||
new RegValue(feature, registryHive, Keys.PRINTER_DRIVER_KEY32, KeyNames.INSTALLATION_DIR, "[INSTALLDIR]"),
|
||||
new RegValue(feature, registryHive, postConverterKey, KeyNames.EXECUTABLE_FILE, Files.POST_CONVERTER),
|
||||
new RegValue(feature, registryHive, preConverterKey, KeyNames.EXECUTABLE_FILE, Files.PRE_CONVERTER),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.SERVER_PORT, 9101) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.THREADS, 2),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.SHOW_PROGRESS, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.PAGES_PER_SHEET, 1),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.FILE_NAME_MASK, "{yyyy}{MM}{DD}{hh}{mm}{ss}{job05}{page03}"),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.OUTPUT_DIR, string.Empty),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.FORMAT, "ps"),
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.MULTIPAGE, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.PRODUCE_PDFA, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ALLOW_COPYING, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ALLOW_PRINTING, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey, KeyNames.SUBSETTING, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterPdfKey,KeyNames.QUALITY , 80),
|
||||
new RegValue(feature, registryHive, converterTiffKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterTiffKey, KeyNames.BITS_PIXEL, 24),
|
||||
new RegValue(feature, registryHive, converterTiffKey, KeyNames.MULTIPAGE, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, converterTiffKey, KeyNames.COMPRESSION, 8)
|
||||
};
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
private static IEnumerable<RegValue> CreateCurrentUserValues(Feature feature, string converterKey)
|
||||
{
|
||||
var redirectKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.CONVERTER_REDIRECT_KEY}";
|
||||
var registryHive = RegistryHive.CurrentUser;
|
||||
|
||||
return new List<RegValue>
|
||||
{
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.PRINT_FORMAT, "PDF"),
|
||||
new RegValue(feature, registryHive, converterKey, KeyNames.RENDER_DPI, 300) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, redirectKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
|
||||
new RegValue(feature, registryHive, redirectKey, KeyNames.PRINTER, "")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A668846E-54C7-483D-9CF7-48F77EA398CA}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VirtualPrinter.WixSharpInstaller</RootNamespace>
|
||||
<AssemblyName>VPDInstaller</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Files\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>VirtualPrinter.WixSharpInstaller.Script</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Script.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="wix\$(ProjectName).g.wxs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\VirtualPrinter.Utils\VirtualPrinter.Utils.csproj">
|
||||
<Project>{cd1c8e9d-5335-41ac-b0c0-88fd7c7c55f3}</Project>
|
||||
<Name>VirtualPrinter.Utils</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
<PackageReference Include="WixSharp.bin" Version="1.14.8" />
|
||||
<PackageReference Include="WixSharp.wix.bin" Version="3.11.2" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- <Import Project="..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets" Condition="Exists('..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets')" />-->
|
||||
<!-- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">-->
|
||||
<!-- <PropertyGroup>-->
|
||||
<!-- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>-->
|
||||
<!-- </PropertyGroup>-->
|
||||
<!-- <Error Condition="!Exists('..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets'))" />-->
|
||||
<!-- <Error Condition="!Exists('..\..\packages\WixSharp\1.14.8\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixSharp\1.14.8\build\WixSharp.targets'))" />-->
|
||||
<!-- </Target>-->
|
||||
</Project>
|
||||
3
Installer/VirtualPrinter.WixSharpInstaller/app.config
Normal file
3
Installer/VirtualPrinter.WixSharpInstaller/app.config
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
|
||||
Loading…
Add table
Add a link
Reference in a new issue