📄 tzhm.h
字号:
}
}
void hdid9x(){
ZeroMemory(&vers,sizeof(vers));
//We start in 95/98/Me
h=CreateFile("\\\\.\\Smartvsd",0,0,0,CREATE_NEW,0,0);
if (!h){
// cout<<"open smartvsd.vxd failed"<<endl;
exit(0);
}
if (!DeviceIoControl(h,DFP_GET_VERSION,0,0,&vers,sizeof(vers),&i,0)){
// cout<<"DeviceIoControl failed:DFP_GET_VERSION"<<endl;
CloseHandle(h);
return;
}
//If IDE identify command not supported, fails
if (!(vers.fCapabilities&1)){
// cout<<"Error: IDE identify command not supported.";
CloseHandle(h);
return;
}
//Display IDE drive number detected
DetectIDE(vers.bIDEDeviceMap);
//Identify the IDE drives
for (j=0;j<4;j++){
PIDSECTOR phdinfo;
char s[41];
ZeroMemory(&in,sizeof(in));
ZeroMemory(&out,sizeof(out));
if (j&1){
in.irDriveRegs.bDriveHeadReg=0xb0;
}else{
in.irDriveRegs.bDriveHeadReg=0xa0;
}
if (vers.fCapabilities&(16>>j)){
//We don't detect a ATAPI device.
// cout<<"Drive "<<(int)(j+1)<<" is a ATAPI device, we don't detect it"<<endl;
continue;
}else{
in.irDriveRegs.bCommandReg=0xec;
}
in.bDriveNumber=j;
in.irDriveRegs.bSectorCountReg=1;
in.irDriveRegs.bSectorNumberReg=1;
in.cBufferSize=512;
if (!DeviceIoControl(h,DFP_RECEIVE_DRIVE_DATA,&in,sizeof(in),&out,sizeof(out),&i,0)){
// cout<<"DeviceIoControl failed:DFP_RECEIVE_DRIVE_DATA"<<endl;
CloseHandle(h);
return;
}
phdinfo=(PIDSECTOR)out.bBuffer;
memcpy(s,phdinfo->sModelNumber,40);
s[40]=0;
ChangeByteOrder(s,40);
// cout<<endl<<"Module Number:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
memcpy(s,phdinfo->sFirmwareRev,8);
s[8]=0;
ChangeByteOrder(s,8);
// cout<<"Firmware rev:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
memcpy(s,phdinfo->sSerialNumber,20);
s[20]=0;
ChangeByteOrder(s,20);
// cout<<"Serial Number:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
// cout<<"\tCapacity:"<<phdinfo->ulTotalAddressableSectors/2/1024<<"M"<<endl<<endl;
}
//Close handle before quit
CloseHandle(h);
// CopyRight();
}
void hdidnt(){
char hd[80];
PIDSECTOR phdinfo;
char s[41];
ZeroMemory(&vers,sizeof(vers));
//We start in NT/Win2000
for (j=0;j<4;j++){
sprintf(hd,"\\\\.\\PhysicalDrive%d",j);
h=CreateFile(hd,GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
if (!h){
continue;
}
if (!DeviceIoControl(h,DFP_GET_VERSION,0,0,&vers,sizeof(vers),&i,0)){
CloseHandle(h);
continue;
}
//If IDE identify command not supported, fails
if (!(vers.fCapabilities&1)){
// cout<<"Error: IDE identify command not supported.";
CloseHandle(h);
return;
}
//Identify the IDE drives
ZeroMemory(&in,sizeof(in));
ZeroMemory(&out,sizeof(out));
if (j&1){
in.irDriveRegs.bDriveHeadReg=0xb0;
}else{
in.irDriveRegs.bDriveHeadReg=0xa0;
}
if (vers.fCapabilities&(16>>j)){
//We don't detect a ATAPI device.
// cout<<"Drive "<<(int)(j+1)<<" is a ATAPI device, we don't detect it"<<endl;
continue;
}else{
in.irDriveRegs.bCommandReg=0xec;
}
in.bDriveNumber=j;
in.irDriveRegs.bSectorCountReg=1;
in.irDriveRegs.bSectorNumberReg=1;
in.cBufferSize=512;
if (!DeviceIoControl(h,DFP_RECEIVE_DRIVE_DATA,&in,sizeof(in),&out,sizeof(out),&i,0)){
// cout<<"DeviceIoControl failed:DFP_RECEIVE_DRIVE_DATA"<<endl;
CloseHandle(h);
return;
}
phdinfo=(PIDSECTOR)out.bBuffer;
memcpy(s,phdinfo->sModelNumber,40);
s[40]=0;
ChangeByteOrder(s,40);
// cout<<endl<<"Module Number:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
memcpy(s,phdinfo->sFirmwareRev,8);
s[8]=0;
ChangeByteOrder(s,8);
// cout<<"Firmware rev:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
memcpy(s,phdinfo->sSerialNumber,20);
s[20]=0;
ChangeByteOrder(s,20);
// cout<<"Serial Number:"<<s<<endl;
CopyMemory( szSystemInfo + uSystemInfoLen, s, strlen(s) );
uSystemInfoLen +=strlen(s);
// cout<<"\tCapacity:"<<phdinfo->ulTotalAddressableSectors/2/1024<<"M"<<endl<<endl;
}
//Close handle before quit
CloseHandle(h);
//CopyRight();
}
void disk()
{
// cout<<"diskinfo:"<<endl;
OSVERSIONINFO VersionInfo;
ZeroMemory(&VersionInfo,sizeof(VersionInfo));
VersionInfo.dwOSVersionInfoSize=sizeof(VersionInfo);
GetVersionEx(&VersionInfo);
switch (VersionInfo.dwPlatformId){
case VER_PLATFORM_WIN32s:
// cout<<"Win32s is not supported by this programm."<<endl;
return;
case VER_PLATFORM_WIN32_WINDOWS:
hdid9x();
return;
case VER_PLATFORM_WIN32_NT:
hdidnt();
}
}
void change_IntToChar(BYTE c[], UINT b)
{
UINT a[4096];
int i = 0;
int j = 0;
while((b/pow(10,j)) > 1){j++;}
j--;
while(b > 0)
{
a[i++] = b/(unsigned int)pow(10,j--);
b = b - a[i-1]*(unsigned int)pow(10,(j+1));
}
a[i] = '\0';
i = 0;
while(a[i] != '\0')
{
c[i] = a[i++] - 0 + '0';
}
c[i] = '\0';
}
///////
// CPU ID
void cpu()
{
// cout<<"cpuinfo:"<<endl;
BOOL bException = FALSE;
BYTE szCpu[16] = { 0 };
UINT uCpuID = 0U;
BYTE CpuID[16] = { 0 }; ///////////////////////
__try
{
_asm
{
mov eax, 0
cpuid
mov dword ptr szCpu[0], ebx
mov dword ptr szCpu[4], edx
mov dword ptr szCpu[8], ecx
mov eax, 1
cpuid
mov uCpuID, edx
}
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
bException = TRUE;
}
///////////////////////////////
change_IntToChar(CpuID, uCpuID);
////////
if( !bException )
{
CopyMemory( szSystemInfo + uSystemInfoLen, CpuID, strlen( (const char *)CpuID ) );
// cout<<"CpuID:"<<CpuID<<endl;
uSystemInfoLen += strlen( (const char *)CpuID );
uCpuID = strlen( ( char* )szCpu );
CopyMemory( szSystemInfo + uSystemInfoLen, szCpu, uCpuID );
// cout<<"szCpu:"<<szCpu<<endl;
uSystemInfoLen += uCpuID;
}
szSystemInfo[uSystemInfoLen] = '\0';
//cout<<uSystemInfoLen<<endl;
j=0;
for(i=0;i<uSystemInfoLen;i++)
{
if(szSystemInfo[i] !=' ')
stemInfonum[j++] = szSystemInfo[i];
}
stemInfonum[j]='\0';
// cout<<"bios_disk_cpuinfonum:"<<stemInfonum<<endl;
}
CString GetTime()
{
CTime time = CTime::GetCurrentTime();
CString str;
char buffer[20];
itoa( time.GetYear(), buffer, 10 );
str = buffer;
itoa( time.GetMonth(), buffer, 10 );
str += buffer;
return str;
}
CString tzhm()
{
CString tzhm;
bios();
disk();
j=0;
for(i=0;i<uSystemInfoLen;i++)
{
if(szSystemInfo[i] !=' ')
stemInfonum[j++] = szSystemInfo[i];
}
stemInfonum[j]='\0';
// cout<<"bios_diskInfonum:"<<stemInfonum<<endl;
cpu();
j=0;
for(i=0;i<uSystemInfoLen;i++)
{
if(szSystemInfo[i] !=' ')
stemInfonum[j++] = szSystemInfo[i];
}
stemInfonum[j]='\0';
// cout<<"szSystemInfonum:"<<stemInfonum<<endl;
// getchar();
//***************
int i=0;
while(stemInfonum[i++]!='\0');
while(i!=0)
tzhm.Insert(0,stemInfonum[--i]);
// tzhm += GetTime();
//********************
return tzhm;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -