国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 數(shù)據(jù)庫 mysql教程 Accessing 64 bit registry from a 32 bit process

Accessing 64 bit registry from a 32 bit process

Jun 07, 2016 pm 03:49 PM
bit from pr registry

As you may know, Windows is virtualizing some parts of the registry under 64 bit. So if you try to open, for example, this key : “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90″, from a 32 bit C# application running on a 6

As you may know, Windows is virtualizing some parts of the registry under 64 bit.

So if you try to open, for example, this key : “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90″, from a 32 bit C# application running on a 64 bit system, you will be redirected to : “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\90″

Why ? Because Windows uses the Wow6432Node registry entry to present a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32 bit applications that runs on a 64 bit systems.

If you want to explicitly open the 64 bit view of the registry, here is what you have to perform :

You are using VS 2010 and version 4.x of the .NET framework

It’s really simple, all you need to do is, instead of doing :

//Will redirect you to the 32 bit view

RegistryKey sqlsrvKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\90");

do the following :

RegistryKey localMachineX64View = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

RegistryKey sqlsrvKey = localMachineX64View.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\90");


Prior versions of the .NET framework

For the prior versions of the framework, we have to use P/Invoke and call the function RegOpenKeyExW with parameter KEY_WOW64_64KEY

enum RegWow64Options

{

????None = 0,

????KEY_WOW64_64KEY = 0x0100,

????KEY_WOW64_32KEY = 0x0200

}

?

enum RegistryRights

{

????ReadKey = 131097,

????WriteKey = 131078

}

?

/// <summary></summary>

/// Open a registry key using the Wow64 node instead of the default 32-bit node.

///

/// <param name="parentKey">Parent key to the key to be opened.

/// <param name="subKeyName">Name of the key to be opened

/// <param name="writable">Whether or not this key is writable

/// <param name="options">32-bit node or 64-bit node

/// <returns></returns>

static RegistryKey _openSubKey(RegistryKey parentKey, string subKeyName, bool writable, RegWow64Options options)

{

????//Sanity check

????if (parentKey == null || _getRegistryKeyHandle(parentKey) == IntPtr.Zero)

????{

????????return null;

????}

?

????//Set rights

????int rights = (int)RegistryRights.ReadKey;

????if (writable)

????????rights = (int)RegistryRights.WriteKey;

?

????//Call the native function >.

????int subKeyHandle, result = RegOpenKeyEx(_getRegistryKeyHandle(parentKey), subKeyName, 0, rights | (int)options, out subKeyHandle);

?

????//If we errored, return null

????if (result != 0)

????{

????????return null;

????}

?

????//Get the key represented by the pointer returned by RegOpenKeyEx

????RegistryKey subKey = _pointerToRegistryKey((IntPtr)subKeyHandle, writable, false);

????return subKey;

}

?

/// <summary></summary>

/// Get a pointer to a registry key.

///

/// <param name="registryKey">Registry key to obtain the pointer of.

/// <returns>Pointer to the given registry key.</returns>

static IntPtr _getRegistryKeyHandle(RegistryKey registryKey)

{

????//Get the type of the RegistryKey

????Type registryKeyType = typeof(RegistryKey);

????//Get the FieldInfo of the 'hkey' member of RegistryKey

????System.Reflection.FieldInfo fieldInfo =

????registryKeyType.GetField("hkey", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

?

????//Get the handle held by hkey

????SafeHandle handle = (SafeHandle)fieldInfo.GetValue(registryKey);

????//Get the unsafe handle

????IntPtr dangerousHandle = handle.DangerousGetHandle();

????return dangerousHandle;

}

?

/// <summary></summary>

/// Get a registry key from a pointer.

///

/// <param name="hKey">Pointer to the registry key

/// <param name="writable">Whether or not the key is writable.

/// <param name="ownsHandle">Whether or not we own the handle.

/// <returns>Registry key pointed to by the given pointer.</returns>

static RegistryKey _pointerToRegistryKey(IntPtr hKey, bool writable, bool ownsHandle)

{

????//Get the BindingFlags for private contructors

????System.Reflection.BindingFlags privateConstructors = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;

????//Get the Type for the SafeRegistryHandle

????Type safeRegistryHandleType = typeof(Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid).Assembly.GetType("Microsoft.Win32.SafeHandles.SafeRegistryHandle");

????//Get the array of types matching the args of the ctor we want

????Type[] safeRegistryHandleCtorTypes = new Type[] { typeof(IntPtr), typeof(bool) };

????//Get the constructorinfo for our object

????System.Reflection.ConstructorInfo safeRegistryHandleCtorInfo = safeRegistryHandleType.GetConstructor(

????privateConstructors, null, safeRegistryHandleCtorTypes, null);

????//Invoke the constructor, getting us a SafeRegistryHandle

????Object safeHandle = safeRegistryHandleCtorInfo.Invoke(new Object[] { hKey, ownsHandle });

?

????//Get the type of a RegistryKey

????Type registryKeyType = typeof(RegistryKey);

????//Get the array of types matching the args of the ctor we want

????Type[] registryKeyConstructorTypes = new Type[] { safeRegistryHandleType, typeof(bool) };

????//Get the constructorinfo for our object

????System.Reflection.ConstructorInfo registryKeyCtorInfo = registryKeyType.GetConstructor(

????privateConstructors, null, registryKeyConstructorTypes, null);

????//Invoke the constructor, getting us a RegistryKey

????RegistryKey resultKey = (RegistryKey)registryKeyCtorInfo.Invoke(new Object[] { safeHandle, writable });

????//return the resulting key

????return resultKey;

}

?

[DllImport("advapi32.dll", CharSet = CharSet.Auto)]

public static extern int RegOpenKeyEx(IntPtr hKey, string subKey, int ulOptions, int samDesired, out int phkResult);


Then we can open our registry key like this :

RegistryKey sqlsrvKey = _openSubKey(Registry.LocalMachine, @"SOFTWARE\Microsoft\Microsoft SQL Server\90", false, RegWow64Options.KEY_WOW64_64KEY);

As you can see, the framework 4 make our life easier.


Referenced from:?http://dotnetgalactics.wordpress.com/2010/05/10/accessing-64-bit-registry-from-a-32-bit-process/

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請(qǐng)聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)

熱門話題

Laravel 教程
1600
29
PHP教程
1502
276
pr的全稱是什么 pr的全稱是什么 Aug 22, 2022 pm 03:53 PM

pr的全稱是“Adobe Premiere Pro”;pr是由Adobe公司開發(fā)的一款視頻編輯軟件,有著較好的兼容性,并且可以與Adobe公司推出的其他軟件相互協(xié)作,廣泛應(yīng)用于廣告制作和電視節(jié)目制作中。

pr有音軌但沒有聲音怎么解決 pr有音軌但沒有聲音怎么解決 Jun 26, 2023 am 11:07 AM

pr有音軌但沒有聲音解決方法:1、在PR應(yīng)用中,將素材拖入時(shí)間軸;2、在編輯菜單中,打開首選項(xiàng);3、在首選項(xiàng)窗口中,打開音頻硬件項(xiàng)目欄,找到默認(rèn)輸出選項(xiàng)框;4、在選項(xiàng)框中,找到揚(yáng)聲器選項(xiàng),點(diǎn)擊確定按鈕;5、回到PR應(yīng)用中,在視頻預(yù)覽窗口中,進(jìn)行播放,就會(huì)有聲音播出。

1bit等于多少字節(jié) 1bit等于多少字節(jié) Mar 09, 2023 pm 03:11 PM

1bit等于八分之一個(gè)字節(jié)。二進(jìn)制數(shù)系統(tǒng)中,每個(gè)0或1就是一個(gè)位(bit),位是數(shù)據(jù)存儲(chǔ)的最小單位;每8個(gè)位(bit,簡(jiǎn)寫為b)組成一個(gè)字節(jié)(Byte),因此“1字節(jié)(Byte)=8位(bit)”。在多數(shù)的計(jì)算機(jī)系統(tǒng)中,一個(gè)字節(jié)是一個(gè)8位(bit)長(zhǎng)的數(shù)據(jù)單位,大多數(shù)的計(jì)算機(jī)用一個(gè)字節(jié)表示一個(gè)字符、數(shù)字或其他字符。

pr文件的壓縮類型不受支持怎么辦 pr文件的壓縮類型不受支持怎么辦 Mar 23, 2023 pm 03:12 PM

pr文件的壓縮類型不受支持的原因及解決辦法:1、精簡(jiǎn)版pr把許多視頻編碼器精簡(jiǎn)掉了,重新安裝使用完整版Premiere;2、視頻編碼不規(guī)范導(dǎo)致的,可以通過格式工廠,將視頻轉(zhuǎn)換成WMV格式即可。

pr字幕怎么逐字出現(xiàn) pr字幕怎么逐字出現(xiàn) Aug 11, 2023 am 10:04 AM

pr字幕逐字出現(xiàn)的方法:1、創(chuàng)建字幕軌道;2、添加字幕文本;3、調(diào)整持續(xù)時(shí)間;4、逐字出現(xiàn)效果;5、調(diào)整動(dòng)畫效果;6、調(diào)整字幕的位置和透明度;7、預(yù)覽和導(dǎo)出視頻。

pr編譯影片時(shí)出錯(cuò)怎么辦 pr編譯影片時(shí)出錯(cuò)怎么辦 Mar 22, 2023 pm 01:59 PM

pr編譯影片時(shí)出錯(cuò)的解決辦法:1、在電腦上打開premiere后期剪輯軟件,然后在項(xiàng)目設(shè)置的右側(cè)菜單欄中,選擇“常規(guī)”;2、進(jìn)入到premiere的常規(guī)設(shè)置窗口,選擇“僅Mercury Playback Engine軟件”;3、點(diǎn)擊“確認(rèn)”即可解決pr編譯影片時(shí)出錯(cuò)問題。

pr外滑工具是干嘛的 pr外滑工具是干嘛的 Jun 30, 2023 am 11:47 AM

pr外滑工具是用來幫助公關(guān)從業(yè)者更好地進(jìn)行PR工作的,具體作用:1、幫助公關(guān)從業(yè)者進(jìn)行媒體監(jiān)測(cè)和分析;2、幫助公關(guān)從業(yè)者進(jìn)行輿情監(jiān)測(cè)和分析;3、幫助公關(guān)從業(yè)者進(jìn)行媒介關(guān)系管理;4、幫助公關(guān)從業(yè)者進(jìn)行新聞稿撰寫和發(fā)布;5、幫助公關(guān)從業(yè)者進(jìn)行數(shù)據(jù)分析和報(bào)告生成。

pr是啥意思 pr是啥意思 Aug 03, 2023 am 10:15 AM

pr是Public Relations的縮寫,是一種重要的組織管理工具,旨在通過建立和維護(hù)良好的關(guān)系來提高組織的聲譽(yù)和信任度。它需要透明度、真實(shí)性和一致性,同時(shí)需要與新媒體和社交媒體緊密結(jié)合。通過有效的pr實(shí)踐,組織可以獲得更廣泛的認(rèn)可和支持,提高其競(jìng)爭(zhēng)力和可持續(xù)發(fā)展能力。

See all articles