哪位高手有在win 7下能获取硬盘序列号的代码,要能用的,分是少了点
谁有在win 7下能获取硬盘序列号的代码,要能用的,分是少了点
谁有在win 7下能获取硬盘序列号的代码,要能用的,分是少了点,现在很急,是软件保护用,
能获取CPU ID等等都行
------解决方案--------------------
LZ很顾家啊,这分确实不多,呵呵!
------解决方案--------------------
哎
都用Windows7跟上潮流了
我还在用XP 无法给你测试
------解决方案--------------------
我昨天在你的另一贴中发过的
http://topic.****.net/u/20100323/14/88c92d01-d825-4cd6-bce1-c23dd1ab8f1d.html
而且我的测试程序就是在win7下用BCB2010写的,以下是我的测试程序,供参考:
谁有在win 7下能获取硬盘序列号的代码,要能用的,分是少了点,现在很急,是软件保护用,
能获取CPU ID等等都行
------解决方案--------------------
LZ很顾家啊,这分确实不多,呵呵!
------解决方案--------------------
哎
都用Windows7跟上潮流了
我还在用XP 无法给你测试
------解决方案--------------------
我昨天在你的另一贴中发过的
http://topic.****.net/u/20100323/14/88c92d01-d825-4cd6-bce1-c23dd1ab8f1d.html
而且我的测试程序就是在win7下用BCB2010写的,以下是我的测试程序,供参考:
- C/C++ code
//---------------------------------------
#include <vcl.h>
#include <comdef.h>
#include <Wbemidl.h>
#pragma comment(lib, "bcbatl.lib")
#pragma hdrstop
void __stdcall _com_issue_error(HRESULT) throw(_com_error)
{
ShowMessage("com error");
}
#include "wmi.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HRESULT hRes;
IWbemLocator * pIWbemLocator = NULL;
IWbemServices * pWbemServices = NULL;
IEnumWbemClassObject * pEnumObject = NULL;
VARIANT v;
//hRes=CoInitializeEx(0, COINIT_MULTITHREADED); //win7 下失败
hRes=CoInitialize(0);
if (FAILED(hRes))
{
ShowMessage(" CoInitializeEx error");
return;
}
//Security needs to be initialized in XP first
if(CoInitializeSecurity( NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_PKT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
0
) != S_OK) //这个初始化只能一次,重新调用要出错的
{
CoUninitialize();
ShowMessage(" CoInitializeSecurity error");
return;
}
BSTR bstrNamespace = (L"\\\\你的机器\\root\\CIMV2");
BSTR name=NULL;
BSTR pass=NULL;
hRes = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pIWbemLocator
);
if (SUCCEEDED(hRes))
{
hRes = pIWbemLocator->ConnectServer(
bstrNamespace, // Namespace
name, // Userid
pass, // PW
NULL, // Locale
0, // flags
NULL, // Authority
NULL, // Context
&pWbemServices
);
}
else
{
ShowMessage(" CoCreateInstance error");
CoUninitialize();
return;
}
hRes = CoSetProxyBlanket(
pWbemServices, //Proxy
RPC_C_AUTHN_DEFAULT, //Authentication service
RPC_C_AUTHZ_DEFAULT, //Authorization service
COLE_DEFAULT_PRINCIPAL, //Server principal name used by authentication service
RPC_C_AUTHN_LEVEL_DEFAULT, //Authentication level
RPC_C_IMP_LEVEL_IMPERSONATE, //Impersonation level
COLE_DEFAULT_AUTHINFO, //Client identity
EOAC_DEFAULT //Capability flags
);
if (FAILED(hRes))
{
ShowMessage(" CoSetProxyBlanket error");
CoUninitialize();
return;
}
//WCHAR temp[200],classname[100];
WCHAR temp[200],*classname; //win7 的 TComboBox的TEXT就是windstring类的
//comb->Text.WideChar(classname,comb->Text.WideCharBufSize());