Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.6 KiB

  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace UDDI
  4. {
  5. public class Win32
  6. {
  7. public static readonly uint HKEY_LOCAL_MACHINE = 0x80000002;
  8. public static readonly uint KEY_READ = 0x00020019;
  9. public static readonly uint KEY_WRITE = 0x00020006;
  10. public static readonly uint KEY_ALL_ACCESS = 0x0002003F;
  11. public static readonly uint REG_NOTIFY_CHANGE_LAST_SET = 0x0004;
  12. public enum ProductType : byte
  13. {
  14. WindowsWorkstation = 0x01,
  15. DomainController = 0x02,
  16. WindowsServer = 0x03
  17. }
  18. [ StructLayout( LayoutKind.Sequential ) ]
  19. public class OsVersionInfo
  20. {
  21. private int size = Marshal.SizeOf( typeof( OsVersionInfo ) );
  22. public uint MajorVersion;
  23. public uint MinorVersion;
  24. public uint BuildNumber;
  25. public uint PlatformID;
  26. [ MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 ) ]
  27. public string AdditionalInformation;
  28. }
  29. [ StructLayout( LayoutKind.Explicit ) ]
  30. public class OsVersionInfoEx
  31. {
  32. [ FieldOffset( 0 ) ]
  33. private int size = Marshal.SizeOf( typeof( OsVersionInfoEx ) );
  34. [ FieldOffset( 4 ) ]
  35. public uint MajorVersion;
  36. [ FieldOffset( 8 ) ]
  37. public uint MinorVersion;
  38. [ FieldOffset( 12 ) ]
  39. public uint BuildNumber;
  40. [ FieldOffset( 16 ) ]
  41. public uint PlatformID;
  42. [ FieldOffset( 20 ), MarshalAs( UnmanagedType.ByValTStr, SizeConst=128 ) ]
  43. public string AdditionalInformation;
  44. [ FieldOffset( 276 ) ]
  45. public ushort ServicePackMajor;
  46. [ FieldOffset( 278 ) ]
  47. public ushort ServicePackMinor;
  48. [ FieldOffset( 280 ) ]
  49. public ushort SuiteMask;
  50. [ FieldOffset( 282 ) ]
  51. public Win32.ProductType ProductType;
  52. [ FieldOffset( 283 ) ]
  53. public byte Reserved;
  54. }
  55. [ DllImport( "kernel32", EntryPoint="GetVersionExW" ) ]
  56. public static extern bool GetVersionEx( [In, Out] OsVersionInfo versionInfo );
  57. [ DllImport( "kernel32", EntryPoint="GetVersionExW" ) ]
  58. public static extern bool GetVersionEx( [In, Out] OsVersionInfoEx versionInfo );
  59. [ DllImport( "advapi32.dll", CharSet=CharSet.Auto ) ]
  60. public static extern int RegCreateKeyEx( uint hkey, string subKey, uint reserved, string className, uint options, uint security, uint attributes, out uint result, uint disposition );
  61. [ DllImport( "advapi32.dll", CharSet=CharSet.Auto ) ]
  62. public static extern int RegNotifyChangeKeyValue( uint hkey, bool watchSubtree, uint notifyFilter, uint eventHandle, bool asynchronous );
  63. [ DllImport( "advapi32.dll", CharSet=CharSet.Auto ) ]
  64. public static extern int RegOpenKeyEx( uint hkey, string subKey, uint options, uint security, out uint result );
  65. }
  66. }