NativeMethod.cs 1.6 KB

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