This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const string userRoot = "HKEY_CURRENT_USER"; | |
| const string subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"; | |
| const string keyName = userRoot + "\\" + subkey; | |
| var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); | |
| var fileInfo = new FileInfo(location.AbsolutePath); | |
| var fileLoc = fileInfo.FullName; | |
| var fileDesc = Path.GetFileNameWithoutExtension(fileInfo.Name); | |
| Registry.SetValue(keyName, fileDesc, fileLoc, RegistryValueKind.String); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| var counters = new List<PerformanceCounter>(); | |
| using (var proc = Process.GetCurrentProcess()) | |
| { | |
| var processorTimeCounter = new PerformanceCounter("Process", "% Processor Time", proc.ProcessName); | |
| processorTimeCounter.NextValue(); | |
| counters.Add(processorTimeCounter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [DllImport("advapi32.dll", SetLastError = true)] | |
| private static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle); | |
| [DllImport("kernel32.dll", SetLastError = true)] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| private static extern bool CloseHandle(IntPtr hObject); | |
| internal static string GetProcessUser(Process process, bool includeDomain = false) | |
| { | |
| var processHandle = IntPtr.Zero; | |
| try |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (object.InvokeRequired) return (bool)object.Invoke(new Func<bool>(() => FunctionName(optionalParameter))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal class HdLogo | |
| { | |
| private static string _hdLogo = ""; | |
| internal static string GetLogo() | |
| { | |
| if (string.IsNullOrEmpty(_hdLogo)) Initialise(); | |
| return _hdLogo; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal static string UppercaseWords(string value) | |
| { | |
| if (string.IsNullOrEmpty(value)) return value; | |
| value = value.ToLower(); | |
| var array = value.ToCharArray(); | |
| if (array.Length >= 1) | |
| { | |
| if (char.IsLower(array[0])) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!string.IsNullOrEmpty(multiLineString)) | |
| { | |
| using (var reader = new StringReader(multiLineString)) | |
| { | |
| string line; | |
| while ((line = reader.ReadLine()) != null) | |
| { | |
| Console.WriteLine(line); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Microsoft Excel object in references-> COM tab | |
| using Excel = Microsoft.Office.Interop.Excel; | |
| var xlApp = new Excel.Application(); | |
| var xlWorkbook = xlApp.Workbooks.Open(Program.XmlFile); | |
| Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; | |
| var xlRange = xlWorksheet.UsedRange; | |
| var rowCount = xlRange.Rows.Count; | |
| var colCount = xlRange.Columns.Count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Concurrent; | |
| using System.ComponentModel; | |
| using System.IO; | |
| using System.Runtime.CompilerServices; | |
| using System.Text.RegularExpressions; | |
| using System.Threading; | |
| using Coderr.Client; | |
| namespace HDSupportIdentifier.Functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal static DateTime GetFirstMonday(int month, int year) | |
| { | |
| var dt = new DateTime(year, month, 1, 12, 00, 00); | |
| for (var i = 0; i < 7; i++) | |
| { | |
| if (dt.DayOfWeek == DayOfWeek.Monday) | |
| { | |
| return dt; | |
| } |