确定使用Win32 API的系统卷驱动器号 [英] determine the system volume drive letter using win32 API

查看:90
本文介绍了确定使用Win32 API的系统卷驱动器号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用win32 API编写C ++应用程序.我想添加一个功能,该功能使用户可以将MBR的内容保存到二进制文件中,MBR用于启动Windows中的当前会话.这应该在多磁盘上工作 配置.

I am writing a C++ application using the win32 API. I would like to add a functionality which would enable users to save the contents of the MBR into a binary file which MBR was used to boot their current session in windows. This should work in multi disk configurations.

所以我发现可以使用CreateFile和ReadFile API来读取引导扇区,但是为此,我需要像这样指定系统卷驱动器:"\\\\.\\ C:".我试图在MSDN中找到有关如何可靠地确定系统的提示 我可以在CreateFile API中使用的驱动器号来读取引导扇区.我发现了这篇文章:http://support.microsoft.com/kb/314470/en-us,然后我试图查找确定系统卷驱动器号的代码.

So I figured out that I can use CreateFile and ReadFile APIs to read the boot sector, but for this I need to specify the system volume drive like this: "\\\\.\\C:". I have tried to find a hint in MSDN about how to reliably determine the system drive letter that I can use in the CreateFile API to read the boot sector. I have found this article: http://support.microsoft.com/kb/314470/en-us and then I was trying to find code to determine the system volume drive letter.

我已经找到了使用WMI的解决方案,但是我的应用程序是进程的插件,如果可能的话,我希望避免使用COM.
我在论坛中发现此键下的内容:HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet某个地方在启动过程中设置了注册表中的值,但我不知道此信息的可靠性.

I have found a solution that uses WMI, but my application is an addin into a process and I would like to avoid using COM if possible.
I have found in forums that under this key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet somewhere there is a value in registry that is set up during the boot process but I do not know how reliable this information is.

我的应用程序需要在XP之后的所有操作系统上运行(意味着XP,Vista,Win7,Server 2003、2008和2008 R2).

My application would need to work on all OSs after XP (meaning XP, Vista, Win7, Server 2003, 2008 and 2008 R2).

任何人都可以让我知道正确执行此操作的推荐方法吗?

Could anyone please let me know what is the recommended way to do this properly?

谢谢您,并致以最诚挚的问候,
Jozsef

Thank you and best regards,
Jozsef

推荐答案

您是否正在寻找GetWindowsDirectory()API?

Are you looking for the GetWindowsDirectory() API?


这篇关于确定使用Win32 API的系统卷驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆