我想使用 Visual Studio 2008 制作一个 Win32 DLL(非托管代码)。选择“新建项目”后,在“项目类型”->“其他语言 ->视觉 C++ -> Win32 我选择Win32 Project 作为项目类型。然后我给它命名并指定位置,然后单击“确定”。在 Win32 应用程序向导中,我选择了以下设置:
是否应该选择 ATL 或 MFC 通用头文件?
此 DLL 的目的是扫描本地系统以查找连接的 USB 设备并返回有关它们的信息。我知道 ManagementObjectSearcher
可用于在 C# 中执行此操作,但我尚未弄清楚如何/是否可以在 C++ 中执行此操作。
I would like to make a Win32 DLL (unmanaged code) using Visual Studio 2008. After selecting New Project, in Project types -> Other Languages -> Visual C++ -> Win32 I selected Win32 Project as the project type. Then I gave it a name and specified the location, and clicked OK. In the Win32 Application Wizard, I have these settings selected:
- Application type: DLL
- Additional options: Export symbols
Should the ATL or MFC common header files be selected?
The purpose of this DLL is to scan the local system for attached USB devices and return information about them. I know ManagementObjectSearcher
can be used to do this in C#, but I haven't yet figured out how/if this can be done in C++.
发布评论
评论(1)
通常,您只需要 COM 的 ATL(因此,如果您确实使用 WMI 用于此任务)。 WMI 是 .Net Framework 中
System.Management
的基础。MFC 是一个通用类库,用于包装 Win32 API,如果有 WMI 支持(我不这么认为 - 列表为 此处)您可能会发现它很有用。
此处有各种 USB 类可供访问通过 WMI。您应该能够枚举
列出系统上存在的内容并输出您需要的内容。请查看此处的 C++ 示例。这很难看,C# 会容易得多。
You only need ATL for COM, generally (so might be marginally useful if you do use WMI for this task). WMI is what underpins
System.Management
in the .Net Framework.MFC is a general-purpose class library built to wrap Win32 APIs, if there is WMI support (I don't think so - list is here) you might find it useful.
There are various USB classes here accessible by WMI. You should be able to enumerate the
list that is present on your system and output what you need. Check out the C++ example here. It's ugly, C# would be a lot easier.