diff --git a/ProgrammList.sln b/ProgrammList.sln
new file mode 100644
index 0000000..1c91ef8
--- /dev/null
+++ b/ProgrammList.sln
@@ -0,0 +1,34 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35527.113 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammList", "ProgrammList\ProgrammList.csproj", "{06D431CD-A938-4DFD-8D77-4C612FDAD914}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ PrgmList|Any CPU = PrgmList|Any CPU
+ PrgmList|x64 = PrgmList|x64
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.ActiveCfg = Release|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|Any CPU.Build.0 = Release|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.ActiveCfg = Debug|x64
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Debug|x64.Build.0 = Debug|x64
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|Any CPU.ActiveCfg = PrgmList|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|Any CPU.Build.0 = PrgmList|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|x64.ActiveCfg = PrgmList|x64
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.PrgmList|x64.Build.0 = PrgmList|x64
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Release|Any CPU.Build.0 = Release|Any CPU
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Release|x64.ActiveCfg = Release|x64
+ {06D431CD-A938-4DFD-8D77-4C612FDAD914}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/ProgrammList/Program.cs b/ProgrammList/Program.cs
new file mode 100644
index 0000000..87e8e9d
--- /dev/null
+++ b/ProgrammList/Program.cs
@@ -0,0 +1,18 @@
+using Microsoft.Extensions.Logging;
+using ProgrammList.ListPrograms;
+
+class Program {
+ static void Main(string[] args) {
+
+ ListPrograms list = new ListPrograms();
+
+ Console.WriteLine("Deleting old data");
+ list.DeleteOldData();
+ string keyname1 = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstal";
+ Console.WriteLine("Searching for 32 bit");
+ list.createList(keyname1, "x86");
+ string keyname2 = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
+ Console.WriteLine("Searching for 64 bit");
+ list.createList(keyname2, "x64");
+ }
+ }
diff --git a/ProgrammList/ProgrammList.csproj b/ProgrammList/ProgrammList.csproj
new file mode 100644
index 0000000..d57e020
--- /dev/null
+++ b/ProgrammList/ProgrammList.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ AnyCPU;x64
+ Debug;Release;PrgmList
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProgrammList/list_creation/ListPrograms.cs b/ProgrammList/list_creation/ListPrograms.cs
new file mode 100644
index 0000000..46daf82
--- /dev/null
+++ b/ProgrammList/list_creation/ListPrograms.cs
@@ -0,0 +1,70 @@
+using Microsoft.Data.SqlClient;
+using Microsoft.Win32;
+using ProgrammList.sql;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using static Mysqlx.Expect.Open.Types.Condition.Types;
+
+namespace ProgrammList.ListPrograms {
+ internal class ListPrograms {
+
+ string prgm_path = Directory.GetCurrentDirectory() + "\\";
+ string[] keyvaluenames = { "DisplayName", "DisplayVersion", "InstallDate"};
+ Mysql sql;
+
+ internal ListPrograms() {
+ sql = new Mysql();
+ }
+
+ internal void DeleteOldData() {
+ sql.checkTableExists();
+ sql.deleteOldData(Dns.GetHostName());
+ }
+
+ internal void createList(string hkey, string bit) {
+ RegistryKey key = Registry.LocalMachine.OpenSubKey(hkey);
+ try {
+ if (key == null) {
+ return;
+ }
+ string[] programmIds = key.GetSubKeyNames();
+
+
+ foreach (string programId in programmIds) {
+
+ RegistryKey programIdSubIds = key.OpenSubKey(programId);
+
+ string result = "";
+ int count = 0;
+ Dictionary value = new Dictionary();
+ for (var i = 0; i <= keyvaluenames.Length - 1; i++) {
+ value.Add(keyvaluenames[i], "'" + (string)programIdSubIds.GetValue(keyvaluenames[i]) + "'");
+ count++;
+ }
+
+ result = String.Join("", value.ToArray());
+
+ if (result.EndsWith(",")) {
+ result = result.Remove(result.Length - 1);
+ }
+
+ value.Add("PCID", "'" + Dns.GetHostName() + "'");
+ value.Add("update_date", "'" + DateTime.Now + "'");
+ value.Add("APP_Architecture", "'" + bit + "'");
+
+
+ sql.InsertOrUpdateData(value);
+ }
+
+ }
+ catch (Exception e) {
+ Console.Error.WriteLine(e.ToString());
+ System.Environment.Exit(1);
+ }
+ }
+ }
+}
diff --git a/ProgrammList/sql/MySql.cs b/ProgrammList/sql/MySql.cs
new file mode 100644
index 0000000..729fc6d
--- /dev/null
+++ b/ProgrammList/sql/MySql.cs
@@ -0,0 +1,159 @@
+using MySql.Data.MySqlClient;
+using System.Data.Common;
+
+namespace ProgrammList.sql {
+
+
+ public class Mysql {
+
+ string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
+
+ public MySqlConnection Connection;
+
+ //private static DbConnection instance;
+ public Mysql() {
+ //string CnnStr = "Data Source=local;Initial Catalog=programlist;User Id=prgmlist;pwd=G0KaUM7TzgO7ZoPZCifs";
+ // instance = new MySqlConnection(CnnStr);
+ }
+
+ public void Open() {
+ string connstring = string.Format("Server={0}; database={1}; UID={2}; password={3}", "localhost", "programlist", "prgmlist", "G0KaUM7TzgO7ZoPZCifs");
+ Connection = new MySqlConnection(connstring);
+ Connection.Open();
+ }
+
+ public void Close() {
+ Connection.Close();
+ }
+
+
+ internal void getAllData() {
+ Open();
+ var command = Connection.CreateCommand();
+ command.CommandText = @"SELECT * FROM list";
+
+ using (var reader = command.ExecuteReader()) {
+ while (reader.Read()) {
+ var dataLine = reader.GetString(0);
+ }
+ }
+ Close();
+ }
+ internal Boolean getSingleLine(string pcid, string program, string version) {
+ Open();
+ var command = Connection.CreateCommand();
+ command.CommandText = @"SELECT * FROM list where PCID like "
+ + pcid + " and DisplayName like "
+ + program + " and DisplayVersion like " + version + ";";
+ var result = command.ExecuteReader().Read();
+
+ Close();
+ return result;
+ }
+
+ internal void checkTableExists() {
+ Open();
+ var command = Connection.CreateCommand();
+ command.CommandText = @"SHOW TABLES LIKE 'list';";
+ var name = command.ExecuteScalar();
+ if (name != null && name.ToString() == "list") {
+ return;
+ }
+ var cols = string.Join(" VARCHAR(255),", valuenames);
+ cols = cols + " Varchar(255)";
+ command.CommandText = "CREATE TABLE list (" + cols + ")";
+ command.ExecuteNonQuery();
+ Close();
+ }
+
+
+ internal void InsertData(Dictionary valuesqlCommand) {
+ Open();
+ var transaction = Connection.BeginTransaction();
+
+ string result = "";
+ for (int i = 0; i < valuenames.Length; i++) {
+ result += valuesqlCommand.GetValueOrDefault(valuenames[i]);
+
+ if (i < valuenames.Length - 1) {
+ result += ",";
+ }
+ }
+
+
+ var cols = String.Join(",", valuenames);
+
+ string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
+
+ var command = new MySqlCommand(sqlCommand, Connection, transaction);
+ command.ExecuteNonQuery();
+ transaction.Commit();
+ Console.WriteLine(sqlCommand);
+ Close();
+ }
+
+ internal void InsertOrUpdateData(Dictionary value) {
+ if (getSingleLine(value.GetValueOrDefault("PCID"), value.GetValueOrDefault("DisplayName"), value.GetValueOrDefault("DisplayVersion"))) {
+ UpdateData(value);
+ }
+ else {
+ InsertData(value);
+ }
+ }
+
+ internal void deleteOldData(string hostname) {
+ Open();
+ var command = Connection.CreateCommand();
+ string sqlCommand = @"delete from list where PCID = '" + hostname + "';";
+ command.CommandText = sqlCommand;
+ command.ExecuteReader();
+ Close();
+ }
+
+ internal void UpdateData(Dictionary value) {
+ Open();
+ var transaction = Connection.BeginTransaction();
+ string sqlCommand = @"Update list ";
+
+ string result = "set ";
+ for (int i = 0; i < valuenames.Length; i++) {
+ result += valuenames[i] + " = " + value.GetValueOrDefault(valuenames[i]);
+
+ if (i < valuenames.Length - 1) {
+ result += " ,";
+ }
+ }
+
+ sqlCommand = sqlCommand + result;
+ sqlCommand = sqlCommand + " WHERE PCID = " + value.GetValueOrDefault("PCID") +
+ " and DisplayName like " + value.GetValueOrDefault("DisplayName") +
+ " and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
+
+
+ var command = new MySqlCommand(sqlCommand, Connection, transaction);
+ for (int i = 0; i < valuenames.Length; i++) {
+ if (valuenames[i] != "PCID") {
+ command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
+ }
+ }
+ Console.WriteLine(sqlCommand);
+ command.ExecuteNonQuery();
+ transaction.Commit();
+ Close();
+ }
+
+ internal void DeleteData(string id) {
+ Open();
+ var command = Connection.CreateCommand();
+ command.CommandText = @"SELECT name FROM user WHERE id = $id";
+ command.Parameters.AddWithValue("$id", id);
+
+ using (var reader = command.ExecuteReader()) {
+ while (reader.Read()) {
+ var name = reader.GetString(0);
+ }
+ }
+ Close();
+ }
+ }
+ }
diff --git a/ProgrammList/sql/SqlBase.cs b/ProgrammList/sql/SqlBase.cs
new file mode 100644
index 0000000..65467d6
--- /dev/null
+++ b/ProgrammList/sql/SqlBase.cs
@@ -0,0 +1,162 @@
+using Microsoft.Data.SqlClient;
+using Microsoft.Data.Sqlite;
+using MySql.Data.MySqlClient;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Transactions;
+using System.Xml.Linq;
+
+namespace ProgrammList.sql {
+
+ /**
+ * Basic commands to connect to the Sqlight database
+ */
+ internal class SqlBase {
+
+ SqliteConnection connection;
+ string prgm_path;
+ string filename;
+
+ string[] valuenames = { "PCID", "DisplayName", "DisplayVersion", "InstallDate", "update_date", "APP_Architecture" };
+
+ /**
+ * Constructor
+ *
+ */
+ internal SqlBase(string prm_path, string file) {
+
+ prgm_path = prm_path + filename;
+ filename = file;
+
+ //connection = new SqliteConnection("Data Source=" + prm_path + filename + " ;PRAGMA journal_mode=WAL;");
+ connection = new SqliteConnection("Data Source=" + prm_path + filename);
+ connection.Open();
+ }
+
+ internal void getAllData() {
+ var command = connection.CreateCommand();
+ command.CommandText = @"SELECT * FROM list";
+
+ using (var reader = command.ExecuteReader()) {
+ while (reader.Read()) {
+ var dataLine = reader.GetString(0);
+ }
+ }
+ }
+ internal Boolean getSingleLine(string pcid, string program, string version) {
+ var command = connection.CreateCommand();
+ command.CommandText = @"SELECT * FROM list where PCID like "
+ + pcid + " and DisplayName like "
+ + program + " and DisplayVersion like " + version + ";";
+
+
+ bool result = command.ExecuteReader().Read();
+
+ return result;
+ }
+
+ internal void checkTableExists() {
+ var command = connection.CreateCommand();
+ command.CommandText = @"SELECT name FROM sqlite_master WHERE type='table' AND name='list';";
+ var name = command.ExecuteScalar();
+ if (name != null && name.ToString() == "list") {
+ return;
+ }
+ var cols = string.Join(" VARCHAR,", valuenames);
+ cols = cols + " Varchar";
+ command.CommandText = "CREATE TABLE list (" +cols + ")";
+ command.ExecuteNonQuery();
+ }
+
+
+ internal void InsertData(Dictionary valuesqlCommand) {
+ var transaction = connection.BeginTransaction();
+
+ string result = "";
+ for (int i = 0; i < valuenames.Length; i++) {
+ result += valuesqlCommand.GetValueOrDefault(valuenames[i]);
+
+ if (i < valuenames.Length -1) {
+ result += ",";
+ }
+ }
+
+
+ var cols = String.Join(",", valuenames);
+
+ string sqlCommand = "INSERT INTO list(" + cols + ")" + "VALUES(" + result + ")";
+
+ var command = new SqliteCommand(sqlCommand, connection, transaction);
+ Console.WriteLine(sqlCommand);
+ command.ExecuteNonQuery();
+ transaction.Commit();
+ }
+
+ internal void InsertOrUpdateData(Dictionary value) {
+ if (getSingleLine(value.GetValueOrDefault("PCID"), value.GetValueOrDefault("DisplayName"), value.GetValueOrDefault("DisplayVersion"))) {
+
+ Console.WriteLine("Update");
+ UpdateData(value);
+ }
+ else {
+
+ Console.WriteLine("Insert");
+ InsertData(value);
+ }
+ }
+
+ internal void deleteOldData(string hostname) {
+ var command = connection.CreateCommand();
+ string sqlCommand = @"delete from list where PCID = '" + hostname + "';";
+ command.CommandText = sqlCommand;
+ command.ExecuteReader();
+ }
+
+ internal void UpdateData(Dictionary value) {
+ var transaction = connection.BeginTransaction();
+ string sqlCommand = @"Update list ";
+
+ string result = "set ";
+ for (int i = 0; i < valuenames.Length; i++) {
+ result += valuenames[i] + " = " + value.GetValueOrDefault(valuenames[i]);
+
+ if (i < valuenames.Length - 1) {
+ result += " ,";
+ }
+ }
+
+ sqlCommand = sqlCommand + result;
+ sqlCommand = sqlCommand + " WHERE PCID = " + value.GetValueOrDefault("PCID") +
+ " and DisplayName like " + value.GetValueOrDefault("DisplayName") +
+ " and DisplayVersion like " + value.GetValueOrDefault("DisplayVersion");
+
+
+ var command = new SqliteCommand(sqlCommand, connection, transaction);
+ for (int i = 0; i < valuenames.Length; i++) {
+ if (valuenames[i] != "PCID") {
+ command.Parameters.AddWithValue("$" + valuenames[i], value.GetValueOrDefault(valuenames[i]));
+ }
+ }
+
+ Console.WriteLine(command.CommandText);
+ command.ExecuteNonQuery();
+ transaction.Commit();
+ }
+
+ internal void DeleteData(string id) {
+ var command = connection.CreateCommand();
+ command.CommandText = @"SELECT name FROM user WHERE id = $id";
+ command.Parameters.AddWithValue("$id", id);
+
+ using (var reader = command.ExecuteReader()) {
+ while (reader.Read()) {
+ var name = reader.GetString(0);
+ }
+ }
+ }
+
+ }
+}