Projekt neu angelegt.
This commit is contained in:
commit
b6c092d508
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#Ignore thumbnails created by Windows
|
||||
Thumbs.db
|
||||
#Ignore files built by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
.vs/
|
||||
#Nuget packages folder
|
||||
packages/
|
||||
1
Daten/Test.txt
Normal file
1
Daten/Test.txt
Normal file
@ -0,0 +1 @@
|
||||
Das ist ein Test.
|
||||
25
StartStopExtProgram.sln
Normal file
25
StartStopExtProgram.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.572
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartStopExtProgram", "StartStopExtProgram\StartStopExtProgram.csproj", "{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {76C786AB-666C-4C58-B65A-1FD47B019205}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
73
StartStopExtProgram/Form1.Designer.cs
generated
Normal file
73
StartStopExtProgram/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
namespace Eugen.ESystem
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Vom Windows Form-Designer generierter Code
|
||||
|
||||
/// <summary>
|
||||
/// Erforderliche Methode für die Designerunterstützung.
|
||||
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonStartStop = new System.Windows.Forms.Button();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonStartStop
|
||||
//
|
||||
this.buttonStartStop.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.buttonStartStop.Location = new System.Drawing.Point(135, 121);
|
||||
this.buttonStartStop.Name = "buttonStartStop";
|
||||
this.buttonStartStop.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonStartStop.TabIndex = 2;
|
||||
this.buttonStartStop.Text = "Start / Stop";
|
||||
this.buttonStartStop.UseVisualStyleBackColor = true;
|
||||
this.buttonStartStop.Click += new System.EventHandler(this.buttonStartStop_Click);
|
||||
//
|
||||
// labelStatus
|
||||
//
|
||||
this.labelStatus.AutoSize = true;
|
||||
this.labelStatus.Location = new System.Drawing.Point(12, 54);
|
||||
this.labelStatus.Name = "labelStatus";
|
||||
this.labelStatus.Size = new System.Drawing.Size(326, 13);
|
||||
this.labelStatus.TabIndex = 0;
|
||||
this.labelStatus.Text = "Start / Stop drücken um das Programm zu Starten oder zu Beenden";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(345, 156);
|
||||
this.Controls.Add(this.labelStatus);
|
||||
this.Controls.Add(this.buttonStartStop);
|
||||
this.Name = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonStartStop;
|
||||
private System.Windows.Forms.Label labelStatus;
|
||||
}
|
||||
}
|
||||
89
StartStopExtProgram/Form1.cs
Normal file
89
StartStopExtProgram/Form1.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Eugen.ESystem
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
#region Version und Copyright
|
||||
// Version und Copyright
|
||||
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
|
||||
string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
||||
string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
||||
string icon = Application.StartupPath + "\\Info.bmp";
|
||||
//Assembly Datum und Zeit
|
||||
static DateTime value = AssemblyDateTime();
|
||||
string date = value.ToShortDateString();
|
||||
string time = value.ToLongTimeString();
|
||||
private static DateTime AssemblyDateTime()
|
||||
{
|
||||
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||
//Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
|
||||
return buildDateTime;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Programm-Info
|
||||
/// <summary>
|
||||
/// Contains the name of the programName file
|
||||
/// </summary>
|
||||
public static string ProgramName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the version of the programName file
|
||||
/// </summary>
|
||||
public static string ProgramVersion { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the copyright notice
|
||||
/// </summary>
|
||||
public static string Copyright { set; get; }
|
||||
|
||||
private void SetProgramInfo()
|
||||
{
|
||||
//Name, Version und Copyright setzen
|
||||
ProgramName = programName;
|
||||
ProgramVersion = programVersion;
|
||||
Copyright = copyright;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Form1()
|
||||
{
|
||||
SetProgramInfo(); //Name, Version und Copyright setzen
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonStartStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
string programPath = @"C:\Windows"; //Programmpfad
|
||||
string programName = "Notepad.exe"; //Programm Name
|
||||
string arg = @"H:\Programmieren\Visual Studio 2017\Projekte\_DLL\StartStopExtProgram\Daten\Test.txt"; //Argument das übergeben wird
|
||||
bool winStyleMinimized = false; //Anzeige des Programmfensters. false=Sichtbar, true=Minimiert
|
||||
|
||||
//Nachfolgend die möglichen Aufrufvarianten
|
||||
try
|
||||
{
|
||||
//var startStop = new StartStopExtProgram(String.Concat(programPath, "\\", programName));
|
||||
//var startStop = new StartStopExtProgram(String.Concat(programPath, "\\", programName), winStyleMinimized);
|
||||
//var startStop = new StartStopExtProgram(String.Concat(programPath, "\\", programName), arg, winStyleMinimized);
|
||||
var startStop = new StartStopExtProgram(programPath, programName, arg, winStyleMinimized);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
StartStopExtProgram/Form1.resx
Normal file
120
StartStopExtProgram/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
108
StartStopExtProgram/Language.Designer.cs
generated
Normal file
108
StartStopExtProgram/Language.Designer.cs
generated
Normal file
@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Eugen.ESystem {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Language {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Language() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Eugen.ESystem.Language", typeof(Language).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Das angegebene Programm wurde nicht gefunden! ähnelt.
|
||||
/// </summary>
|
||||
internal static string message001 {
|
||||
get {
|
||||
return ResourceManager.GetString("message001", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Der angegebene Programmname wurde nicht gefunden! ähnelt.
|
||||
/// </summary>
|
||||
internal static string message002 {
|
||||
get {
|
||||
return ResourceManager.GetString("message002", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Der angegebene Programmpfad wurde nicht gefunden! ähnelt.
|
||||
/// </summary>
|
||||
internal static string message003 {
|
||||
get {
|
||||
return ResourceManager.GetString("message003", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Der Prozessname konnte nicht generiert werden! ähnelt.
|
||||
/// </summary>
|
||||
internal static string message004 {
|
||||
get {
|
||||
return ResourceManager.GetString("message004", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Programm konnte nicht gestartet werden! ähnelt.
|
||||
/// </summary>
|
||||
internal static string message005 {
|
||||
get {
|
||||
return ResourceManager.GetString("message005", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
0
StartStopExtProgram/Language.de.Designer.cs
generated
Normal file
0
StartStopExtProgram/Language.de.Designer.cs
generated
Normal file
135
StartStopExtProgram/Language.de.resx
Normal file
135
StartStopExtProgram/Language.de.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="message001" xml:space="preserve">
|
||||
<value>Das angegebene Programm wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message002" xml:space="preserve">
|
||||
<value>Der angegebene Programmname wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message003" xml:space="preserve">
|
||||
<value>Der angegebene Programmpfad wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message004" xml:space="preserve">
|
||||
<value>Der Prozessname konnte nicht generiert werden!</value>
|
||||
</data>
|
||||
<data name="message005" xml:space="preserve">
|
||||
<value>Programm konnte nicht gestartet werden!</value>
|
||||
</data>
|
||||
</root>
|
||||
135
StartStopExtProgram/Language.en.resx
Normal file
135
StartStopExtProgram/Language.en.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="message001" xml:space="preserve">
|
||||
<value>The specified program was not found!</value>
|
||||
</data>
|
||||
<data name="message002" xml:space="preserve">
|
||||
<value>The specified program name was not found!</value>
|
||||
</data>
|
||||
<data name="message003" xml:space="preserve">
|
||||
<value>The specified program path was not found!</value>
|
||||
</data>
|
||||
<data name="message004" xml:space="preserve">
|
||||
<value>The process name could not be generated!</value>
|
||||
</data>
|
||||
<data name="message005" xml:space="preserve">
|
||||
<value>Program could not be started!</value>
|
||||
</data>
|
||||
</root>
|
||||
135
StartStopExtProgram/Language.resx
Normal file
135
StartStopExtProgram/Language.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="message001" xml:space="preserve">
|
||||
<value>Das angegebene Programm wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message002" xml:space="preserve">
|
||||
<value>Der angegebene Programmname wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message003" xml:space="preserve">
|
||||
<value>Der angegebene Programmpfad wurde nicht gefunden!</value>
|
||||
</data>
|
||||
<data name="message004" xml:space="preserve">
|
||||
<value>Der Prozessname konnte nicht generiert werden!</value>
|
||||
</data>
|
||||
<data name="message005" xml:space="preserve">
|
||||
<value>Programm konnte nicht gestartet werden!</value>
|
||||
</data>
|
||||
</root>
|
||||
22
StartStopExtProgram/Program.cs
Normal file
22
StartStopExtProgram/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Eugen.ESystem
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
StartStopExtProgram/Properties/AssemblyInfo.cs
Normal file
36
StartStopExtProgram/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("StartStopExtProgram")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("StartStopExtProgram")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019 by Eugen Höglinger")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("d9fa7eae-2785-4856-bd44-1320c7e3bd39")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
322
StartStopExtProgram/StartStopExtProgram.cs
Normal file
322
StartStopExtProgram/StartStopExtProgram.cs
Normal file
@ -0,0 +1,322 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Eugen.ESystem
|
||||
{
|
||||
public class StartStopExtProgram
|
||||
{
|
||||
/// <summary>
|
||||
/// Starts or stops an external program.
|
||||
/// </summary>
|
||||
/// <param name="program">A valid program name with path and extension.</param>
|
||||
public StartStopExtProgram(string program)
|
||||
{
|
||||
SetBaseValues(program);
|
||||
StartStop(String.Concat(ProgramPath, "\\", Program), Arg, WinStyleMinimized, ProcessName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts or stops an external program in declared window style.
|
||||
/// </summary>
|
||||
/// <param name="program">A valid program name with path and extension.</param>
|
||||
/// <param name="winStyleMinimized">Window style: false=visible, true=minimized.</param>
|
||||
public StartStopExtProgram(string program, bool winStyleMinimized)
|
||||
{
|
||||
SetBaseValues(program, winStyleMinimized);
|
||||
StartStop(String.Concat(ProgramPath, "\\", Program), Arg, WinStyleMinimized, ProcessName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts or stops an external program in declared window style and transfer parameter.
|
||||
/// </summary>
|
||||
/// <param name="program">A valid program name with path and extension.</param>
|
||||
/// <param name="arg">A valid transfer parameter.</param>
|
||||
/// <param name="winStyleMinimized">Window style: false=visible, true=minimized.</param>
|
||||
public StartStopExtProgram(string program, string arg, bool winStyleMinimized)
|
||||
{
|
||||
SetBaseValues(program, arg, winStyleMinimized);
|
||||
StartStop(String.Concat(ProgramPath, "\\", Program), Arg, WinStyleMinimized, ProcessName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts or stops an external program in declared window style and transfer parameter.
|
||||
/// </summary>
|
||||
/// <param name="programPath">A valid program path.</param>
|
||||
/// <param name="programName">A valid program name with extension.</param>
|
||||
/// <param name="arg">A valid transfer parameter.</param>
|
||||
/// <param name="winStyleMinimized">Window style: false=visible, true=minimized.</param>
|
||||
public StartStopExtProgram(string programPath, string programName, string arg, bool winStyleMinimized)
|
||||
{
|
||||
SetBaseValues(programPath, programName, arg, winStyleMinimized);
|
||||
StartStop(String.Concat(ProgramPath, "\\", Program), Arg, WinStyleMinimized, ProcessName);
|
||||
}
|
||||
|
||||
protected string ProgramPath { set; get; }
|
||||
protected string Program { set; get; }
|
||||
protected string Arg { set; get; }
|
||||
protected bool WinStyleMinimized { set; get; }
|
||||
protected string ProcessName { set; get; }
|
||||
|
||||
private void SetBaseValues(string program)
|
||||
{
|
||||
if (File.Exists(program))
|
||||
{
|
||||
Program = Path.GetFileName(program);
|
||||
ProgramPath = Path.GetDirectoryName(program);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NoValidProgramNameException(Language.message001);
|
||||
}
|
||||
|
||||
Arg = "";
|
||||
WinStyleMinimized = false;
|
||||
|
||||
ProcessName = SetProcessName(program);
|
||||
}
|
||||
|
||||
private void SetBaseValues(string program, bool winStyleMinimized)
|
||||
{
|
||||
if (File.Exists(program))
|
||||
{
|
||||
Program = Path.GetFileName(program);
|
||||
ProgramPath = Path.GetDirectoryName(program);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NoValidProgramNameException(Language.message001);
|
||||
}
|
||||
|
||||
Arg = "";
|
||||
WinStyleMinimized = winStyleMinimized;
|
||||
|
||||
ProcessName = SetProcessName(program);
|
||||
}
|
||||
|
||||
private void SetBaseValues(string program, string arg, bool winStyleMinimized)
|
||||
{
|
||||
if (File.Exists(program))
|
||||
{
|
||||
Program = Path.GetFileName(program);
|
||||
ProgramPath = Path.GetDirectoryName(program);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NoValidProgramNameException(Language.message001);
|
||||
}
|
||||
|
||||
Arg = arg;
|
||||
WinStyleMinimized = winStyleMinimized;
|
||||
|
||||
ProcessName = SetProcessName(program);
|
||||
}
|
||||
|
||||
private void SetBaseValues(string programPath, string programName, string arg, bool winStyleMinimized)
|
||||
{
|
||||
if (Directory.Exists(programPath))
|
||||
{
|
||||
ProgramPath = programPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NoValidFolderStructureException(Language.message003);
|
||||
}
|
||||
|
||||
if (File.Exists(String.Concat(programPath, "\\", programName)))
|
||||
{
|
||||
Program = programName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NoValidProgramNameException(Language.message002);
|
||||
}
|
||||
|
||||
Arg = arg;
|
||||
WinStyleMinimized = winStyleMinimized;
|
||||
|
||||
ProcessName = SetProcessName(programName);
|
||||
}
|
||||
|
||||
private string SetProcessName(string program)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(program))
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append(program.Substring(0, 1).ToUpper() + program.Substring(1));
|
||||
return Path.GetFileNameWithoutExtension(sb.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnableToGenerateProcessNameException(Language.message002);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartStop(string program, string arg, bool winStyle, string processName)
|
||||
{
|
||||
if (!CheckProcessIsRun(processName))
|
||||
{
|
||||
Start(program, arg, winStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stop(program);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckProcessIsRun(string processName)
|
||||
{
|
||||
//Prüfen ob der Prozess läuft
|
||||
return (Process.GetProcessesByName(processName).Length > 0);
|
||||
}
|
||||
|
||||
private void Start(string program, string arg, bool winStyle)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessStartInfo startProgram = new ProcessStartInfo(program);
|
||||
startProgram.Arguments = arg;
|
||||
if (winStyle)
|
||||
{
|
||||
startProgram.WindowStyle = ProcessWindowStyle.Minimized;
|
||||
}
|
||||
Process.Start(startProgram);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new UnableToRunProgramException(Language.message005);
|
||||
}
|
||||
}
|
||||
|
||||
private void Stop(string program)
|
||||
{
|
||||
try
|
||||
{
|
||||
string process = program.Remove(0, program.LastIndexOf(@"\") + 1);
|
||||
process = process.Remove(process.Length - 4);
|
||||
|
||||
Process[] close = Process.GetProcessesByName(process);
|
||||
close[0].CloseMainWindow();
|
||||
close[0].Kill();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new UnableToStopProgramException("Programm konnte nicht beendet werden!\n\n" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Exceptions
|
||||
class NoValidFolderStructureException : ApplicationException
|
||||
{
|
||||
public NoValidFolderStructureException()
|
||||
{
|
||||
}
|
||||
|
||||
public NoValidFolderStructureException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public NoValidFolderStructureException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class NoValidProgramNameException : ApplicationException
|
||||
{
|
||||
public NoValidProgramNameException()
|
||||
{
|
||||
}
|
||||
|
||||
public NoValidProgramNameException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public NoValidProgramNameException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownErrorException : ApplicationException
|
||||
{
|
||||
public UnknownErrorException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnknownErrorException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnknownErrorException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class UnableToRunProgramException : ApplicationException
|
||||
{
|
||||
public UnableToRunProgramException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToRunProgramException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToRunProgramException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class UnableToStopProgramException : ApplicationException
|
||||
{
|
||||
public UnableToStopProgramException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToStopProgramException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToStopProgramException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class UnableToGenerateProcessNameException : ApplicationException
|
||||
{
|
||||
public UnableToGenerateProcessNameException()
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToGenerateProcessNameException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnableToGenerateProcessNameException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
84
StartStopExtProgram/StartStopExtProgram.csproj
Normal file
84
StartStopExtProgram/StartStopExtProgram.csproj
Normal file
@ -0,0 +1,84 @@
|
||||
<?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>{D9FA7EAE-2785-4856-BD44-1320C7E3BD39}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Eugen.ESystem</RootNamespace>
|
||||
<AssemblyName>StartStopExtProgram</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>false</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Language.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Language.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Language.de.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Language.de.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="StartStopExtProgram.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Language.en.resx" />
|
||||
<EmbeddedResource Include="Language.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Language.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Language.de.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Language.de.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user