Program.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Windows.Forms;
  3. using System.DirectoryServices.AccountManagement;
  4. using System.Drawing;
  5. using System.IO;
  6. /*
  7. Author: @bitsadmin
  8. Website: https://github.com/bitsadmin
  9. License: BSD 3-Clause
  10. */
  11. namespace FakeLogonScreen
  12. {
  13. static class Program
  14. {
  15. /// <summary>
  16. /// The main entry point for the application.
  17. /// </summary>
  18. [STAThread]
  19. static void Main()
  20. {
  21. Application.EnableVisualStyles();
  22. Application.SetCompatibleTextRenderingDefault(false);
  23. // Initialize new screen
  24. LogonScreen s = new LogonScreen();
  25. // Set background
  26. string imagePath = @"C:\Windows\Web\Screen\img100.jpg";
  27. if (File.Exists(imagePath))
  28. s.BackgroundImage = Image.FromFile(imagePath);
  29. else
  30. s.BackColor = Color.FromArgb(0, 90, 158);
  31. // Set username
  32. s.Username = Environment.UserName;
  33. s.Context = ContextType.Machine;
  34. try
  35. {
  36. UserPrincipal user = UserPrincipal.Current;
  37. s.Username = user.SamAccountName;
  38. s.DisplayName = user.DisplayName;
  39. s.Context = user.ContextType;
  40. }
  41. catch (Exception) { }
  42. // Show
  43. Application.Run(s);
  44. }
  45. }
  46. }