【发布时间】:2015-05-16 06:25:47
【问题描述】:
我想制作一个只允许您在一台计算机上使用我的程序的系统,有点像许可证系统。 例如:程序检查系统的卷信息,如果与允许它运行的卷匹配,则运行。
我的两个问题是, 1. 这两种获取系统音量的方式有什么区别?
int main()
{
cout << GetVolumeInformation << endl;
system("pause");
}
string GetMachineID()
{
DWORD dwSerial;
ostringstream oss;
if (!GetVolumeInformation(TEXT("C:\\"), NULL, 0, &dwSerial, NULL, NULL, NULL, 0))
{
oss << "Err_Not_Retrieved_" << GetLastError();
}
else
oss << dwSerial;
return oss.str();
}
string machid = GetMachineID();
const char *cstr = machid.c_str();
int main()
{
cout << cstr << endl;
system("pause");
}
它们各自返回不同的值,(第一个:xxxxxxxx 数字和字母,第二个:xxxxxxxxxx only numbers)那么有什么区别? 我的第二个问题是,我应该使用其中哪一个来达到我的目的?
【问题讨论】:
-
你的第一次尝试打印出一个函数地址...
-
您的标题是非描述性的。把它改成合理的东西。