NativeMethods.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Security;
  4. namespace TurnoffMonitorOnLock.IconExtract
  5. {
  6. internal static class NativeMethods
  7. {
  8. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
  9. [SuppressUnmanagedCodeSecurity]
  10. public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);
  11. [DllImport("kernel32.dll", SetLastError = true)]
  12. [SuppressUnmanagedCodeSecurity]
  13. public static extern bool FreeLibrary(IntPtr hModule);
  14. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
  15. [SuppressUnmanagedCodeSecurity]
  16. public static extern bool EnumResourceNames(IntPtr hModule, IntPtr lpszType, Enumresnameproc lpEnumFunc, IntPtr lParam);
  17. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
  18. [SuppressUnmanagedCodeSecurity]
  19. public static extern IntPtr FindResource(IntPtr hModule, IntPtr lpName, IntPtr lpType);
  20. [DllImport("kernel32.dll", SetLastError = true)]
  21. [SuppressUnmanagedCodeSecurity]
  22. public static extern IntPtr LoadResource(IntPtr hModule, IntPtr hResInfo);
  23. [DllImport("kernel32.dll", SetLastError = true)]
  24. [SuppressUnmanagedCodeSecurity]
  25. public static extern IntPtr LockResource(IntPtr hResData);
  26. [DllImport("kernel32.dll", SetLastError = true)]
  27. [SuppressUnmanagedCodeSecurity]
  28. public static extern uint SizeofResource(IntPtr hModule, IntPtr hResInfo);
  29. }
  30. [UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)]
  31. [SuppressUnmanagedCodeSecurity]
  32. internal delegate bool Enumresnameproc(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam);
  33. }