public static void ModifyReservation(string urlPrefix, string accountName, bool removeReservation) { Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET hTTPSERVICECONFIGURLACLSET = new Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET(); string str = HttpReservation.CreateSddl(accountName); hTTPSERVICECONFIGURLACLSET.Key.UrlPrefix = urlPrefix; hTTPSERVICECONFIGURLACLSET.Param.Sddl = str; Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTPAPI_VERSION hTTPAPIVERSION = new Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTPAPI_VERSION(1, 0); int num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpInitialize(hTTPAPIVERSION, 2, IntPtr.Zero); if (num != 0) { throw HttpReservation.GetException("HttpInitialize", num); } try { if (removeReservation) { num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpDeleteServiceConfigurationAcl(IntPtr.Zero, 2, ref hTTPSERVICECONFIGURLACLSET, Marshal.SizeOf(typeof(Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET)), IntPtr.Zero); } num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpSetServiceConfigurationAcl(IntPtr.Zero, 2, ref hTTPSERVICECONFIGURLACLSET, Marshal.SizeOf(typeof(Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET)), IntPtr.Zero); if (num != 0) { throw HttpReservation.GetException("HttpSetServiceConfigurationAcl", num); } } finally { Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpTerminate(2, IntPtr.Zero); } }
public static bool ArePortsReserved(string urlPrefix, string accountName) { Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET hTTPSERVICECONFIGURLACLSET = new Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET(); bool flag; bool flag1 = false; string str = HttpReservation.CreateSddl(accountName); hTTPSERVICECONFIGURLACLSET.Key.UrlPrefix = urlPrefix; hTTPSERVICECONFIGURLACLSET.Param.Sddl = str; Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTPAPI_VERSION hTTPAPIVERSION = new Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTPAPI_VERSION(1, 0); int num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpInitialize(hTTPAPIVERSION, 2, IntPtr.Zero); if (num != 0) { throw HttpReservation.GetException("HttpInitialize", num); } try { num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpDeleteServiceConfigurationAcl(IntPtr.Zero, 2, ref hTTPSERVICECONFIGURLACLSET, Marshal.SizeOf(typeof(Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET)), IntPtr.Zero); if (num != 0) { flag1 = false; } else { num = Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpSetServiceConfigurationAcl(IntPtr.Zero, 2, ref hTTPSERVICECONFIGURLACLSET, Marshal.SizeOf(typeof(Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HTTP_SERVICE_CONFIG_URLACL_SET)), IntPtr.Zero); if (num != 0) { throw HttpReservation.GetException("HttpSetServiceConfigurationAcl", num); } flag1 = true; } flag = flag1; } finally { Microsoft.WindowsAzure.Storage.Emulator.Controller.NativeMethods.HttpTerminate(2, IntPtr.Zero); } return(flag); }