C++如何将系统序列号传递到变量中?
我已经能够检索我的系统序列号,但如何将序列号本身传递到变量中?
int main()
{
char newSerial;
int (*ptr) (const char[]);
ptr = system;
ptr("wmic bios get serialnumber");
}
运行我的代码后,屏幕显示:
SerialNumber
xxxxxxxxxxxxx
完全像这样。但我想要的是将“x”传递到 char 变量中,因为它里面有一个破折号。程序到底从哪里调用序列号?有什么建议吗? (Windows 7 x64)
I've been able to retrieve my system serial number, but how do I pass the serial number itself into a variable?
int main()
{
char newSerial;
int (*ptr) (const char[]);
ptr = system;
ptr("wmic bios get serialnumber");
}
After running my code, the screen displays:
SerialNumber
xxxxxxxxxxxxx
exactly like this. But what I want is to pass just the "x's" into a char variable since it has a dash in it. Where exactly is the program calling the serial number from? Any suggestions? (Windows 7 x64)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过 C++ 以编程方式访问 WMI 的官方认可方法是 WMI 的 COM API。具体请参阅 WMI 下的示例C++ 应用示例。
另一方面,如果您希望快速访问序列号,请在程序中添加以下内容:
The officially sanctioned way to get programatic access to WMI through C++ is the COM API for WMI. See specifically the examples under WMI C++ Application Examples.
If on the other hand, you want quick access to the serial number, add something along these lines to your program:
这是一种不使用文本文件的更好方法
Here is a better approach without using text file