32bit 程式在 64bit Windows 上寫 Registry 的神祕小知識

Jack Yu
Jack Yu
Feb 24, 2017 · 2 min read

這是個考驗有沒有認真讀文件的時候了。32bit 程式在 64bit Windows 上寫 Registry 到底會有什麼狀況呢?

答案是 — — 微軟認為 32bit 和 64bit 的程式在讀 registry 可能會有不同的行為,因此當 32bit 程式透過 API 讀寫 registry 時,Windows 會貼心的自動轉換實際上的 registry key 路徑,讓 32bit 和 64bit 程式操縱的 registry 可以分開。

例如操作 HKEY_LOCAL_MACHINE\SOFTWARE\… 實際上會跑到 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\…

針對這個狀況,微軟的 API 也有開相對應的flag 可以來修改行為, 例如 KEY_WOW64_64KEY 可以讓 32bit 的正常操作正確位置的 registry。

Reference

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade