Skip to content

Commit

Permalink
Added config file and net4.8.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidVolker committed Feb 11, 2024
1 parent ddf68aa commit a6c9aa9
Show file tree
Hide file tree
Showing 34 changed files with 2,815 additions and 1,196 deletions.
662 changes: 332 additions & 330 deletions .gitignore

Large diffs are not rendered by default.

86 changes: 61 additions & 25 deletions LogonService/LogonService.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.421
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogonService", "LogonService\LogonService.csproj", "{FAC83616-9681-45D0-B15E-407D2059ABCA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {41D7B4FD-3D91-4917-9DB2-12F95CCD167F}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogonServiceNet4.5.1", "LogonService\LogonServiceNet4.5.1.csproj", "{FAC83616-9681-45D0-B15E-407D2059ABCA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogonServiceNet4.8.1", "LogonService_4.8.1\LogonServiceNet4.8.1.csproj", "{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|Any CPU.Build.0 = Release|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|ARM64.Build.0 = Debug|ARM64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|x64.ActiveCfg = Debug|x64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|x64.Build.0 = Debug|x64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|x86.ActiveCfg = Debug|x86
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Debug|x86.Build.0 = Debug|x86
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|Any CPU.Build.0 = Release|Any CPU
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|ARM64.ActiveCfg = Release|ARM64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|ARM64.Build.0 = Release|ARM64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|x64.ActiveCfg = Release|x64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|x64.Build.0 = Release|x64
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|x86.ActiveCfg = Release|x86
{FAC83616-9681-45D0-B15E-407D2059ABCA}.Release|x86.Build.0 = Release|x86
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|Any CPU.Build.0 = Release|Any CPU
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|ARM64.Build.0 = Debug|ARM64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|x64.ActiveCfg = Debug|x64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|x64.Build.0 = Debug|x64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|x86.ActiveCfg = Debug|x86
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Debug|x86.Build.0 = Debug|x86
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|Any CPU.Build.0 = Release|Any CPU
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|ARM64.ActiveCfg = Release|ARM64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|ARM64.Build.0 = Release|ARM64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|x64.ActiveCfg = Release|x64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|x64.Build.0 = Release|x64
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|x86.ActiveCfg = Release|x86
{FF02D228-C61A-431B-8EFE-78BCAECB7FC3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {41D7B4FD-3D91-4917-9DB2-12F95CCD167F}
EndGlobalSection
EndGlobal
27 changes: 21 additions & 6 deletions LogonService/LogonService/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.5.1" />
</startup>
<appSettings>
<add key="OnLogon"
value=""/>
<add key="LogEnabled"
value="false"/>
<add key="LogPath"
value=""/>
<add key="Description"
value="Logon Service for running applications on logon screen"/>
<add key="DisplayName"
value="Logon Service"/>
<add key="ServiceName"
value="LogonService"/>
</appSettings>
</configuration>
22 changes: 22 additions & 0 deletions LogonService/LogonService/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Configuration;

namespace LogonService
{
internal static class AppConfig
{
public static string OnLogon = Get("OnLogon", "");
public static string LogEnabled = Get("LogEnabled", "false");
public static string LogPath = Get("LogPath", $"{AppDomain.CurrentDomain.BaseDirectory}log.txt");
public static string Description = Get("Description", "Logon Service for running applications on logon screen");
public static string DisplayName = Get("DisplayName", "Logon Service");
public static string ServiceName = Get("ServiceName", "LogonService");

public static string Get(string prop, string defProp = null)
{
var value = ConfigurationManager.AppSettings[prop];
if (string.IsNullOrEmpty(value)) { value = defProp; }
return value;
}
}
}
230 changes: 115 additions & 115 deletions LogonService/LogonService/Args.cs
Original file line number Diff line number Diff line change
@@ -1,115 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace LogonService
{
class Args : Dictionary<string, Args.Command>
{
public char[] prefixes = { '/', '-' };
public Action<string> msg = (s) => Console.WriteLine(s);
public struct Command
{
public bool isParsed;
public string usage;
public Func<string[], int, Action<string>, int> action;
public Command(Func<string[], int, Action<string>, int> a, string u = "")
{
isParsed = false;
action = a;
usage = u;
}
}

public string Usage()
{
string r = "";
foreach (KeyValuePair<string, Args.Command> cmd in this)
{
if (prefixes.Length > 0)
{
r += " ";
//r + = prefixes.Join(cmd.Key, " ")
foreach (char c in prefixes)
{
r += c + cmd.Key + " ";
}
r += " —— " + cmd.Value.usage + "\n";
}
else
{
r += " " + cmd.Key + " —— " + cmd.Value.usage + "\n";
}

}
return r;
}

public void Parse(string[] args)
{
int len = args.Length;
string argument;
//int cmdres = 0;
int i = 0;
while (i < len)
{
//msg("i= " + i + " len= " + len + (i < len).ToString());
Command cmd;
argument = args[i];
if (prefixes.Length > 0)
{
if (prefixes.Contains(argument[0]))
{
argument = argument.Substring(1);
if (TryGetValue(argument, out cmd))
{
if (cmd.isParsed)
{
msg("Argument already parsed: " + argument);
return;
}
else
{
cmd.isParsed = true;
this[argument] = cmd;
i = cmd.action(args, i + 1, msg);
continue;
}

}
}
}
else
{
if (TryGetValue(argument, out cmd))
{
if (cmd.isParsed)
{
msg("Argument already parsed: " + argument);
return;
}
else
{
cmd.isParsed = true;
this[argument] = cmd;
i = cmd.action(args, i + 1, msg);
continue;
}
}
}
msg(" Unknown argument: " + argument + "\n" + Usage());
return;
}
}

public Args()
{
Add("h", new Command((string[] a, int next, Action<string> m) =>
{
m(Usage());
return next;
}, " Show all commands help")
);
}
}
}
//using System;
//using System.Collections.Generic;
//using System.Linq;

//namespace LogonService
//{
// class Args : Dictionary<string, Args.Command>
// {
// public char[] prefixes = { '/', '-' };
// public Action<string> msg = (s) => Console.WriteLine(s);
// public struct Command
// {
// public bool isParsed;
// public string usage;
// public Func<string[], int, Action<string>, int> action;
// public Command(Func<string[], int, Action<string>, int> a, string u = "")
// {
// isParsed = false;
// action = a;
// usage = u;
// }
// }

// public string Usage()
// {
// string r = "";
// foreach (KeyValuePair<string, Args.Command> cmd in this)
// {
// if (prefixes.Length > 0)
// {
// r += " ";
// //r + = prefixes.Join(cmd.Key, " ")
// foreach (char c in prefixes)
// {
// r += c + cmd.Key + " ";
// }
// r += " —— " + cmd.Value.usage + "\n";
// }
// else
// {
// r += " " + cmd.Key + " —— " + cmd.Value.usage + "\n";
// }

// }
// return r;
// }

// public void Parse(string[] args)
// {
// int len = args.Length;
// string argument;
// //int cmdres = 0;
// int i = 0;
// while (i < len)
// {
// //msg("i= " + i + " len= " + len + (i < len).ToString());
// Command cmd;
// argument = args[i];
// if (prefixes.Length > 0)
// {
// if (prefixes.Contains(argument[0]))
// {
// argument = argument.Substring(1);
// if (TryGetValue(argument, out cmd))
// {
// if (cmd.isParsed)
// {
// msg("Argument already parsed: " + argument);
// return;
// }
// else
// {
// cmd.isParsed = true;
// this[argument] = cmd;
// i = cmd.action(args, i + 1, msg);
// continue;
// }

// }
// }
// }
// else
// {
// if (TryGetValue(argument, out cmd))
// {
// if (cmd.isParsed)
// {
// msg("Argument already parsed: " + argument);
// return;
// }
// else
// {
// cmd.isParsed = true;
// this[argument] = cmd;
// i = cmd.action(args, i + 1, msg);
// continue;
// }
// }
// }
// msg(" Unknown argument: " + argument + "\n" + Usage());
// return;
// }
// }

// public Args()
// {
// Add("h", new Command((string[] a, int next, Action<string> m) =>
// {
// m(Usage());
// return next;
// }, " Show all commands help")
// );
// }
// }
//}
Loading

0 comments on commit a6c9aa9

Please sign in to comment.