Win32.RegOpenKeyEx C# (CSharp) Method

RegOpenKeyEx() private method

private RegOpenKeyEx ( uint hKey, string lpSubKey, uint ulOptions, int samDesired, int &phkResult ) : int
hKey uint
lpSubKey string
ulOptions uint
samDesired int
phkResult int
return int
    static extern int RegOpenKeyEx(uint hKey, string lpSubKey, uint ulOptions, int samDesired, out int phkResult);

Usage Example

Example #1
0
        private static IEnumerable <string> LocalInstances(uint flag)
        {
            // Get local instances for us
            var mssqlKey = UIntPtr.Zero;

            try
            {
                Win32.RegOpenKeyEx(Win32.HKEY_LOCAL_MACHINE, @"Software\Microsoft\Microsoft SQL Server", 0, Win32.KEY_QUERY_VALUE | flag, out mssqlKey);

                if (mssqlKey == UIntPtr.Zero)
                {
                    return(new List <string>());
                }

                var instances = Win32.RegQueryValue(mssqlKey, "InstalledInstances") as string[];
                if (instances == null)
                {
                    return(new List <string>());
                }

                return(new List <string>(instances));
            }
            finally
            {
                if (mssqlKey != UIntPtr.Zero)
                {
                    Win32.RegCloseKey(mssqlKey);
                }
            }
        }
All Usage Examples Of Win32::RegOpenKeyEx