当前位置: 首页>>代码示例>>C#>>正文


C# RegistryOptions类代码示例

本文整理汇总了C#中RegistryOptions的典型用法代码示例。如果您正苦于以下问题:C# RegistryOptions类的具体用法?C# RegistryOptions怎么用?C# RegistryOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RegistryOptions类属于命名空间,在下文中一共展示了RegistryOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSubKeyInternalCore

        private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, bool writable, RegistryOptions registryOptions)
        {
            Interop.mincore.SECURITY_ATTRIBUTES secAttrs = default(Interop.mincore.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.mincore.RegCreateKeyEx(_hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                (int)GetRegistryKeyRights(writable) | (int)_regView,
                ref secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, writable, false, _remoteKey, false, _regView);
                if (subkey.Length == 0)
                {
                    key._keyName = _keyName;
                }
                else
                {
                    key._keyName = _keyName + "\\" + subkey;
                }
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
            {
                Win32Error(ret, _keyName + "\\" + subkey);  // Access denied?
            }

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:38,代码来源:RegistryKey.Windows.cs

示例2: CreateSubKey

 public unsafe RegistryKey CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck,  RegistryOptions registryOptions, RegistrySecurity registrySecurity) 
 {
     return CreateSubKeyInternal(subkey, permissionCheck, registrySecurity, registryOptions);
 }        
开发者ID:afrog33k,项目名称:csnative,代码行数:4,代码来源:RegistryKey.cs

示例3: CreateSubKeyInternal

        private unsafe RegistryKey CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            ValidateKeyMode(permissionCheck);            
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash
            
            // only keys opened under read mode is not writable
            if (!remoteKey) {
                RegistryKey key = InternalOpenSubKey(subkey, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree));
                if (key != null)  { // Key already exits
                    CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
                    CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
                    key.checkMode = permissionCheck;
                    return key;
                }
            }

            CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);      

            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;

            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Win32Native.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)regView,
                secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid) {
                RegistryKey key = new RegistryKey(result, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree), false, remoteKey, false, regView);                
                CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);                
                key.checkMode = permissionCheck;
                
                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            BCLDebug.Assert(false, "Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:54,代码来源:RegistryKey.cs

示例4: CreateSubKeyInternal

        private RegistryKey CreateSubKeyInternal(string subkey, bool writable, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!_remoteKey)
            {
                RegistryKey key = InternalOpenSubKey(subkey, writable);
                if (key != null)
                { 
                    // Key already exits
                    return key;
                }
            }

            return CreateSubKeyInternalCore(subkey, writable, registryOptions);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:20,代码来源:RegistryKey.cs

示例5: CreateSubKey

		public RegistryKey CreateSubKey (RegistryKey rkey, string keyName, RegistryOptions options)
		{
			IntPtr handle = GetHandle (rkey);
			IntPtr subKeyHandle;
			int disposition;
			int result = RegCreateKeyEx (handle , keyName, 0, IntPtr.Zero,
				options == RegistryOptions.Volatile ? RegOptionsVolatile : RegOptionsNonVolatile,
				OpenRegKeyRead | OpenRegKeyWrite, IntPtr.Zero, out subKeyHandle, out disposition);

			if (result == Win32ResultCode.MarkedForDeletion)
				throw RegistryKey.CreateMarkedForDeletionException ();

			if (result != Win32ResultCode.Success)
				GenerateException (result);
			
			return new RegistryKey (subKeyHandle, CombineName (rkey, keyName),
				true);
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:18,代码来源:Win32RegistryApi.cs

示例6: CreateSubKey

 public RegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity registrySecurity)
 {
   return default(RegistryKey);
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:4,代码来源:Microsoft.Win32.RegistryKey.cs

示例7: RegistryOptionsTestsValid

        public void RegistryOptionsTestsValid(bool alreadyExists, RegistryOptions options)
        {
            string subkey = "TEST_" + options.ToString();

            if (alreadyExists)
            {
                TestRegistryKey.CreateSubKey(subkey);
            }

            Assert.NotNull(TestRegistryKey.CreateSubKey(subkey));
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:RegistryKey_CreateSubKey_str_rkpc.cs

示例8: CreateSubKey

		public RegistryKey CreateSubKey (string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
		{
			AssertKeyStillValid ();
			AssertKeyNameNotNull (subkey);
			AssertKeyNameLength (subkey);

			if (!IsWritable)
				throw new UnauthorizedAccessException ("Cannot write to the registry key.");

			return RegistryApi.CreateSubKey (this, subkey, options);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:RegistryKey.cs

示例9: CreateSubKeyInternal

        private unsafe RegistryKey CreateSubKeyInternal(String subkey, bool writable, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash

            // only keys opened under read mode is not writable
            if (!remoteKey)
            {
                RegistryKey key = InternalOpenSubKey(subkey, writable);
                if (key != null)
                { // Key already exits
                    return key;
                }
            }

            Interop.mincore.SECURITY_ATTRIBUTES secAttrs = default(Interop.mincore.SECURITY_ATTRIBUTES);
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Interop.mincore.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(writable) | (int)regView,
                ref secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid)
            {
                RegistryKey key = new RegistryKey(result, writable, false, remoteKey, false, regView);

                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            Debug.Fail("Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:48,代码来源:RegistryKey.cs

示例10: CreateRegistry

 public virtual IServiceRegistry CreateRegistry(RegistryOptions options)
 {
     return new GenericRegistry(options.RegistryDataStore, options.RegistryNotify, options.Watcher);
 }
开发者ID:tukzer,项目名称:Seif,代码行数:4,代码来源:GenericRegistryFactory.cs

示例11: CreateSubKeyInternal

 private unsafe RegistryKey CreateSubKeyInternal(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
 {
     ValidateKeyOptions(registryOptions);
     ValidateKeyName(subkey);
     ValidateKeyMode(permissionCheck);
     this.EnsureWriteable();
     subkey = FixupName(subkey);
     if (!this.remoteKey)
     {
         RegistryKey key = this.InternalOpenSubKey(subkey, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree);
         if (key != null)
         {
             this.CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
             this.CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
             key.checkMode = permissionCheck;
             return key;
         }
     }
     this.CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);
     Win32Native.SECURITY_ATTRIBUTES structure = null;
     RegistrySecurity security = (RegistrySecurity) registrySecurityObj;
     if (security != null)
     {
         structure = new Win32Native.SECURITY_ATTRIBUTES {
             nLength = Marshal.SizeOf(structure)
         };
         byte[] securityDescriptorBinaryForm = security.GetSecurityDescriptorBinaryForm();
         byte* pDest = stackalloc byte[(IntPtr) securityDescriptorBinaryForm.Length];
         Buffer.memcpy(securityDescriptorBinaryForm, 0, pDest, 0, securityDescriptorBinaryForm.Length);
         structure.pSecurityDescriptor = pDest;
     }
     int lpdwDisposition = 0;
     SafeRegistryHandle hkResult = null;
     int errorCode = Win32Native.RegCreateKeyEx(this.hkey, subkey, 0, null, (int) registryOptions, GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, this.regView), structure, out hkResult, out lpdwDisposition);
     if ((errorCode == 0) && !hkResult.IsInvalid)
     {
         RegistryKey key2 = new RegistryKey(hkResult, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, false, this.remoteKey, false, this.regView);
         this.CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
         key2.checkMode = permissionCheck;
         if (subkey.Length == 0)
         {
             key2.keyName = this.keyName;
             return key2;
         }
         key2.keyName = this.keyName + @"\" + subkey;
         return key2;
     }
     if (errorCode != 0)
     {
         this.Win32Error(errorCode, this.keyName + @"\" + subkey);
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:53,代码来源:RegistryKey.cs

示例12: GetRegistry

 public IServiceRegistry GetRegistry(RegistryOptions options)
 {
     return CreateRegistry(options);
 }
开发者ID:tukzer,项目名称:Seif,代码行数:4,代码来源:GenericRegistryFactory.cs

示例13: CreateSubKey

 /// <summary>
 /// TODO: Add Comment
 /// </summary>
 /// <param name="subkey"></param>
 /// <param name="permissionCheck"></param>
 /// <param name="registryOptions"></param>
 /// <param name="registrySecurity"></param>
 /// <returns></returns>
 public IRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, IRegistrySecurity registrySecurity)
 {
     RegistryKey key = RegistryKeyInstance.CreateSubKey(subkey, permissionCheck, registryOptions, registrySecurity.RegistrySecurityInstance);
     if (null == key)
         return null;
     else
         return new RegistryKeyWrap(key);
 }
开发者ID:gjhwssg,项目名称:SystemWrapper,代码行数:16,代码来源:RegistryKeyWrap.cs

示例14: CreateSubKeyInternal

        private unsafe RegistryKey CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
        {
            ValidateKeyOptions(registryOptions);
            ValidateKeyName(subkey);
            ValidateKeyMode(permissionCheck);            
            EnsureWriteable();
            subkey = FixupName(subkey); // Fixup multiple slashes to a single slash
            
            // only keys opened under read mode is not writable
            if (!remoteKey) {
                RegistryKey key = InternalOpenSubKey(subkey, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree));
                if (key != null)  { // Key already exits
                    CheckPermission(RegistryInternalCheck.CheckSubKeyWritePermission, subkey, false, RegistryKeyPermissionCheck.Default);
                    CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);
                    key.checkMode = permissionCheck;
                    return key;
                }
            }

            CheckPermission(RegistryInternalCheck.CheckSubKeyCreatePermission, subkey, false, RegistryKeyPermissionCheck.Default);      
            
            Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
#if FEATURE_MACL
            RegistrySecurity registrySecurity = (RegistrySecurity)registrySecurityObj;
            // For ACL's, get the security descriptor from the RegistrySecurity.
            if (registrySecurity != null) {
                secAttrs = new Win32Native.SECURITY_ATTRIBUTES();
                secAttrs.nLength = (int)Marshal.SizeOf(secAttrs);

                byte[] sd = registrySecurity.GetSecurityDescriptorBinaryForm();
                // We allocate memory on the stack to improve the speed.
                // So this part of code can't be refactored into a method.
                byte* pSecDescriptor = stackalloc byte[sd.Length];
                Buffer.Memcpy(pSecDescriptor, 0, sd, 0, sd.Length);
                secAttrs.pSecurityDescriptor = pSecDescriptor;
            }
#endif
            int disposition = 0;

            // By default, the new key will be writable.
            SafeRegistryHandle result = null;
            int ret = Win32Native.RegCreateKeyEx(hkey,
                subkey,
                0,
                null,
                (int)registryOptions /* specifies if the key is volatile */,
                GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)regView,
                secAttrs,
                out result,
                out disposition);

            if (ret == 0 && !result.IsInvalid) {
                RegistryKey key = new RegistryKey(result, (permissionCheck != RegistryKeyPermissionCheck.ReadSubTree), false, remoteKey, false, regView);                
                CheckPermission(RegistryInternalCheck.CheckSubTreePermission, subkey, false, permissionCheck);                
                key.checkMode = permissionCheck;
                
                if (subkey.Length == 0)
                    key.keyName = keyName;
                else
                    key.keyName = keyName + "\\" + subkey;
                return key;
            }
            else if (ret != 0) // syscall failed, ret is an error code.
                Win32Error(ret, keyName + "\\" + subkey);  // Access denied?

            BCLDebug.Assert(false, "Unexpected code path in RegistryKey::CreateSubKey");
            return null;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:68,代码来源:RegistryKey.cs

示例15: ValidateKeyOptions

 private static void ValidateKeyOptions(RegistryOptions options)
 {
 }
开发者ID:stephentoub,项目名称:corert,代码行数:3,代码来源:RegistryKey.cs


注:本文中的RegistryOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。