如何使用 Free Pascal 调用物理连接的硬盘列表,或者如果失败,则使用 Delphi?
进一步了解此问题和这个,我最近问过,但没有正确的细节......最后这个是我在 Free Pascal 论坛上专门问的......
可以任何人都可以向我提供指导、示例或某个地方的链接,解释如何使用 Free Pascal 调用物理连接的硬盘列表,或者如果失败,则使用 Delphi,无论磁盘是否已由操作系统安装或 不是?我试图实现的屏幕截图中显示了一个示例(此屏幕截图中显示的是另一个软件产品)。因此,提取逻辑卷列表(C:\、E:\ 等)并不是我想要做的。如果磁盘有操作系统无法安装的文件系统,我仍然想查看列出的物理磁盘。
我强调 C\C++\C Sharp 的例子很多,但不是我所追求的。我主要需要 Free Pascal 示例,或者,如果做不到这一点,则需要 Delphi。
Further to this question and this one that I asked more recently but without the correct specifics...and lastly this one that I asked at the Free Pascal forum specifically....
Can anyone provide me with guidance, examples or a link to something somewhere that explains how to call a list of the physically attached hard disks using Free Pascal, or, failing that, Delphi, regardless of whether the disks have been mounted by the operating system or not? An example is shown in the screenshot of what I am trying to achive (what is shown in this screenshot is by another software product). So pulling a list of logical volumes (C:\, E:\ etc) is not what I am trying to do. And if the disk has a filesystem that the operating system cannot mount, I still want to see the physical disk listed.
I stress that C\C++\C Sharp examples are plentifull but not what I am after. I need primarily Free Pascal example, or, failing that, Delphi.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
Win32_DiskDrive
WMI 类,检查此示例代码运行此代码后,您将得到如下输出
Try the
Win32_DiskDrive
WMI class, check this sample codeAfter of running this code you will get a output like this
对于带有驱动器号的已安装驱动器,请调用 Win32 ShellApi 函数
SHGetSpecialFolderLocation(0, CSIDL_DRIVES, Drives)
。声明局部变量Drives: PItemIdList
。这是delphi 中名为ShellAPI
的单元。希望 FreePascal 中存在类似的单元。对于未安装的驱动器,您必须通过 GUID_DEVINTERFACE_DISK 的设备驱动程序类以某种方式枚举设备驱动程序。 windows的SetupAPI应该可以帮助你。
您可以从 JEDI JCL 或 JEDI API 项目获取SetupAPI.pas。
包含上述代码和相应 JEDI API 单元的完整工作 DELPHI 示例为 这里。您可以轻松地将其适应 free pascal 和 lazarus。
For mounted drives with drive letters, call Win32 ShellApi function
SHGetSpecialFolderLocation(0, CSIDL_DRIVES, Drives)
. Declare local variableDrives: PItemIdList
. This is in unit namedShellAPI
in delphi. Hopefully a similar unit exists in FreePascal.For unmounted drives, you will have to enumerate the device drivers by the device driver class of
GUID_DEVINTERFACE_DISK
somehow. The SetupAPI of windows should be able to help you.You can get SetupAPI.pas from the JEDI JCL or JEDI API projects.
A complete working DELPHI example including the above code and the appropriate JEDI API units is here. You can adapt it to free pascal and lazarus pretty easily.