public static bool GetDWord(HKey key, string value, out int result) { uint cbData = 4; AdvApi32.RegistryValueType type = AdvApi32.RegistryValueType.DWord; IntPtr resultValue = MemoryPool.Allocate(4); bool ret = false; if (AdvApi32.RegQueryValueExW(key, value, 0, ref type, resultValue, ref cbData) == 0) { result = Marshal.PtrToStructure <int>(resultValue); ret = true; } else { result = 0; } MemoryPool.Free(resultValue); return(ret); }
private static bool QueryValueStringW(HKey hKey, string lpValueName, IntPtr lpData, uint cbData) { AdvApi32.RegistryValueType type = AdvApi32.RegistryValueType.Sz; return(AdvApi32.RegQueryValueExW(hKey, lpValueName, 0, ref type, lpData, ref cbData) == 0); }
private static bool QueryValueLengthW(HKey hKey, string lpValueName, ref uint lpcbData) { AdvApi32.RegistryValueType type = AdvApi32.RegistryValueType.Binary; return(AdvApi32.RegQueryValueExW(hKey, lpValueName, 0, ref type, IntPtr.Zero, ref lpcbData) == 0); }