|
Hi!
I like this small app.
I'm wondering if it's possible to also display the OS Language used, User language, keyboard settings etc.
Are there any API's for this?
Thanks!
|
|
|
|
|
You need to add the pack paragma to your code. I noticed that the data in your structures was misaligned when I was modifying your code to retrieve the temperature of the hard drive.
#pragma pack(1)
//---------------------------------------------------------------------
// The following structure defines the structure of a Drive Attribute
//---------------------------------------------------------------------
typedef struct _DRIVEATTRIBUTE {
BYTE bAttrID; // Identifies which attribute
WORD wStatusFlags; // see bit definitions below
BYTE bAttrValue; // Current normalized value
BYTE bWorstValue; // How bad has it ever been?
BYTE bRawValue[6]; // Un-normalized value
BYTE bReserved; // ...
} DRIVEATTRIBUTE, *PDRIVEATTRIBUTE, *LPDRIVEATTRIBUTE;
//---------------------------------------------------------------------
// The following structure defines the structure of a Warranty Threshold
// Obsoleted in ATA4!
//---------------------------------------------------------------------
typedef struct _ATTRTHRESHOLD {
BYTE bAttrID; // Identifies which attribute
BYTE bWarrantyThreshold; // Triggering value
BYTE bReserved[10]; // ...
} ATTRTHRESHOLD, *PATTRTHRESHOLD, *LPATTRTHRESHOLD;
//---------------------------------------------------------------------
// The following struct defines the interesting part of the IDENTIFY
// buffer:
//---------------------------------------------------------------------
typedef struct _IDSECTOR {
USHORT wGenConfig;
USHORT wNumCyls;
USHORT wReserved;
USHORT wNumHeads;
USHORT wBytesPerTrack;
USHORT wBytesPerSector;
USHORT wSectorsPerTrack;
USHORT wVendorUnique[3];
CHAR sSerialNumber[20];
USHORT wBufferType;
USHORT wBufferSize;
USHORT wECCSize;
CHAR sFirmwareRev[8];
CHAR sModelNumber[40];
USHORT wMoreVendorUnique;
USHORT wDoubleWordIO;
USHORT wCapabilities;
USHORT wReserved1;
USHORT wPIOTiming;
USHORT wDMATiming;
USHORT wBS;
USHORT wNumCurrentCyls;
USHORT wNumCurrentHeads;
USHORT wNumCurrentSectorsPerTrack;
ULONG ulCurrentSectorCapacity;
USHORT wMultSectorStuff;
ULONG ulTotalAddressableSectors;
USHORT wSingleWordDMA;
USHORT wMultiWordDMA;
BYTE bReserved[128];
} IDSECTOR, *PIDSECTOR;
#pragma pack()
*** The following might be useful updates too:
ULONGLONG PrintSmartAttribRawValue(PCHAR szOut, PDRIVEATTRIBUTE attribute)
{
ULONGLONG rawvalue;
BYTE word[3];
int j;
// convert the six individual bytes to a long long (8 byte) integer.
// This is the value that we'll eventually return.
rawvalue = 0;
for (j = 0; j < 6; j++)
{
// This looks a bit roundabout, but is necessary. Don't
// succumb to the temptation to use raw[j]<<(8*j) since under
// the normal rules this will be promoted to the native type.
// On a 32 bit machine this might then overflow.
ULONGLONG temp;
temp = attribute->bRawValue[j];
temp <<= 8*j;
rawvalue |= temp;
}
// convert quantities to three two-byte words
for(j = 0; j < 3; j++)
{
word[j] = attribute->bRawValue[2*j+1];
word[j] <<= 8;
word[j] |= attribute->bRawValue[2*j];
}
// This switch statement is where we handle Raw attributes
// that are stored in an unusual vendor-specific format,
switch (attribute->bAttrID)
{
// Spin-up time
case 3:
szOut += sprintf(szOut, "%d", word[0]);
// if second nonzero then it stores the average spin-up time
if(word[1])
szOut += sprintf(szOut, " (Average %d)", word[1]);
break;
// Power on time
case 9:
szOut += sprintf(szOut, "%I64u", rawvalue); //stored in hours
break;
// Load unload cycles
case 193:
szOut += sprintf(szOut, "%I64u", rawvalue);
break;
// Temperature
case 194:
szOut += sprintf(szOut, "%d", word[0]);
if (!(rawvalue==word[0]))
{
int min = word[1] < word[2]? word[1]: word[2];
int max = word[1] > word[2]? word[1]: word[2];
// The other bytes are in use. Try IBM's model
szOut += sprintf(szOut, " (Lifetime Min/Max %d/%d)", min, max);
}
break;
default:
szOut += sprintf(szOut, "%I64u", rawvalue);
break;
}
// Return the full value
return rawvalue;
}
// Note some attribute names appear redundant because different
// manufacturers use different attribute IDs for an attribute with the
// same name. The variable val should contain a non-zero value if a particular
// attributes has a non-default interpretation.
PCHAR GetSmartAttribName(BYTE id)
{
PCHAR szName = "Unknown_Attribute";
switch(id)
{
case 1: szName = "Raw Read Error Rate"; break;
case 2: szName = "Throughput Performance"; break;
case 3: szName = "Spin Up Time"; break;
case 4: szName = "Start Stop Count"; break;
case 5: szName = "Reallocated Sector Ct"; break;
case 6: szName = "Read Channel Margin"; break;
case 7: szName = "Seek Error Rate"; break;
case 8: szName = "Seek Time Performance"; break;
case 9: szName = "Power On Hours"; break;
case 10: szName = "Spin Retry Count"; break;
case 11: szName = "Calibration Retry Count"; break;
case 12: szName = "Power Cycle Count"; break;
case 13: szName = "Read Soft Error Rate"; break;
case 191: szName = "G-Sense Error Rate"; break;
case 192: szName = "Power-Off Retract Count"; break;
case 193: szName = "Load Cycle Count"; break;
case 194: szName = "Temperature Celsius"; break;
case 195: szName = "Hardware ECC Recovered"; break;
case 196: szName = "Reallocated Event Count"; break;
case 197: szName = "Current Pending Sector"; break;
case 198: szName = "Offline Uncorrectable"; break;
case 199: szName = "UDMA CRC Error Count"; break;
case 200: szName = "Write Error Count"; break;
case 201: szName = "Detected TA Count"; break;
case 202: szName = "TA Increase Count"; break;
case 203: szName = "Run Out Cancel"; break;
case 204: szName = "Shock Count Write Opern"; break;
case 205: szName = "Shock Rate Write Opern"; break;
case 206: szName = "Flying Height"; break;
case 207: szName = "Spin High Current"; break;
case 208: szName = "Spin Buzz"; break;
case 209: szName = "Offline Seek Performnce"; break;
case 220: szName = "Disk Shift"; break;
case 221: szName = "G-Sense Error Rate"; break;
case 222: szName = "Loaded Hours"; break;
case 223: szName = "Load Retry Count"; break;
case 224: szName = "Load Friction"; break;
case 225: szName = "Load Cycle Count"; break;
case 226: szName = "Load-in Time"; break;
case 227: szName = "Torq-amp Count"; break;
case 228: szName = "Power-off Retract Count"; break;
case 230: szName = "Head Amplitude"; break;
case 231: szName = "Temperature Celsius"; break;
case 240: szName = "Head Flying Hours"; break;
case 250: szName = "Read Error Retry Rate"; break;
default: szName = "Unknown Attribute"; break;
}
return szName;
}
/****************************************************************************
*
* DoPrintData
*
* FUNCTION: Display the SMART Attributes and Thresholds
*
****************************************************************************/
CString DoPrintData(PCHAR pAttrBuffer, PCHAR pThrsBuffer, BYTE bDriveNum)
{
int i;
PDRIVEATTRIBUTE pDA;
PATTRTHRESHOLD pAT;
BYTE Attr;
CString Result;
//
// Print the drive number
//
char Temp[512]="";
sprintf(Temp,"\r\nData for Drive Number %d\n", bDriveNum);
Result+=Temp;
//
// Print the revisions of the data structures
//
sprintf(Temp, "Attribute Structure Revision Threshold Structure Revision\r\n");
Result+=Temp;
sprintf(Temp," %d %d\r\n\r\n",
(WORD)pAttrBuffer[0],
(WORD)pThrsBuffer[0]);
Result+=Temp;
//
// Print the header and loop through the structures, printing
// the structures when the attribute ID is known.
//
sprintf(Temp, " -Attribute Name- -Attribute Value- -Threshold Value- -Raw Value-\r\n");
Result+=Temp;
pDA = (PDRIVEATTRIBUTE)&pAttrBuffer[2];
pAT = (PATTRTHRESHOLD)&pThrsBuffer[2];
for (i = 0; i < NUM_ATTRIBUTE_STRUCTS; i++)
{
Attr = pDA->bAttrID;
char szOut[64] = {0};
PrintSmartAttribRawValue(szOut, pDA);
if (Attr)
{
sprintf(Temp,"%2X %-29s%d%20c%d %s\r\n",
pDA->bAttrID,
GetSmartAttribName(pDA->bAttrID),
pDA->bAttrValue,
' ',
pAT->bWarrantyThreshold, szOut);
Result+=Temp;
}
pDA++;
pAT++;
}
return Result;
}
|
|
|
|
|
hi, im getting 102 errors in the file SysInfoDefs.cpp
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(7) : error C2065: 'SENDCMDOUTPARAMS' : undeclared identifier
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(14) : error C2061: syntax error : identifier 'PSENDCMDINPARAMS'
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(22) : error C2065: 'PSENDCMDINPARAMS' : undeclared identifier
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(695) : error C2065: 'DRIVE_LAYOUT_INFORMATION_EX' : undeclared identifier
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(695) : error C2146: syntax error : missing ';' before identifier 'dli'
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(695) : error C2065: 'dli' : undeclared identifier
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(709) : error C2065: 'IOCTL_DISK_GET_DRIVE_LAYOUT_EX' : undeclared identifier
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(718) : error C2228: left of '.PartitionCount' must have class/struct/union type
D:\Programming\game programming\LEARNING\MFC\1\SysInfoDefs.cpp(721) : error C2228: left of '.PartitionCount' must have class/struct/union type
etc...
what could be wrong? thx
|
|
|
|
|
As I said in previous messages, you must have the latest Platform SDK (PSDK) and also must included before MFC header file definitions.
Best regards,
A. Riazi
|
|
|
|
|
hi all,
this is a great app. however, i noticed that for windows xp, the o.s. query returns windows 2000. is there a way to modify the program, so it will return xp as well?
|
|
|
|
|
You need to modify the source codes a little. See the header definitions.
Best regards,
A. Riazi
|
|
|
|
|
amir,
what would the IsWindowsXP function look like. what particular settings would distinguish it???? i know that it is in the windows nt family.
|
|
|
|
|
Hi,
I'm Abbas not Amir! The build number is useful for distinguish the Windows XP OS. I used another article from CP (Author: PJ Naughter) to wrote it.
Best regards,
A. Riazi
|
|
|
|
|
The current code seems to be unable to get centrino cpu speed. I have a 1.5GHz, and the returned CPU speed always varies from 500MHz to 1000MHz. What's scoop? Also, a 1.5GHz centrino is said equivalent to 2.4GHz regular cpu(more or less). How do we formally reflect this in the cpu speed?
|
|
|
|
|
I think it is because centrino cpu's have 'SpeedStep'. E.g. their speed changes depending on load.
|
|
|
|
|
All around a good package but.
1. there are missing code to handle *ALL* SMART HD details, because other ID codes are like 0xC2 for temperature. So the code needs to be changed to loop through all values, not just 12. To get the rest download hdtune.com's program, it lists them all. The code could also do with a function to read a specific AttrID of the SMART data but return the rawvalue, NOT THE AttrValue. I did that my self, and added a GetAttrIDValue( id, &result ) function.
2. one structure used a BYTE, then a WORD which stuffed up the auto padding with visual C++. I suggest that you ALWAYS use a BYTE halfs if your WORD is on an ODD boundary.
structure in question should be; (in smartdefs.h)
typedef struct _DRIVEATTRIBUTE {
BYTE bAttrID; // Identifies which attribute
BYTE wStatusFlagsL; // see bit definitions below
BYTE wStatusFlagsH; // see bit definitions below
BYTE bAttrValue; // Current normalized value
BYTE bWorstValue; // How bad has it ever been?
BYTE bRawValue[6]; // Un-normalized value
BYTE bReserved; // ...
} DRIVEATTRIBUTE, *PDRIVEATTRIBUTE, *LPDRIVEATTRIBUTE;
This GURANTEES it to work no matter what compiler you have, besides you dont even use that status flags any how.
Thats all... Enjoy the fix.
Hows the skiing in IRAN btw?
_______________________________
Raul Software Engineer (www.ac3dec.com
|
|
|
|
|
Thanks Raul,
Would you please to send me your code that I can share it with others?
Best regards,
A. Riazi
|
|
|
|
|
hummm... that part is just a "bad" copy/paste from the Microsoft example "smartapp":
http://download.microsoft.com/download/winddk/sample3/9x/W9X/EN-US/SmartApp.exe
why bad? cause it's not doing correctly the job... (founding 4 hard drives with your tool but 2, the real number, with the microsoft example)
next time try to copy/paste better
some good SMART sources there:
http://smartmontools.sourceforge.net/
cheers
-- modified at 0:12 Thursday 29th September, 2005
|
|
|
|
|
In the first release of the code, I didn't provide the S.M.A.R.T. infos but after some suggestions from others (like Raul Sobon) that you see under previous threads, I grabbed their source codes and add to mine.
Then it is not copy/paste, I didn't know that Microsoft has this!
Best regards,
A. Riazi
|
|
|
|
|
ok ok... if you have some free time maybe can you try to correct your code and add SMART scan on other disk than PhysicalDrive0 (when more than 1 drive... on NT based here)
cheers
bruno
|
|
|
|
|
I'm working on WMI version of my app. This new version queries all hardwares and give you more detailed info.
Unfortunately I haven't enough time now, may in future.
Best regards,
A. Riazi
|
|
|
|
|
is it possible that the check gives a wrong value when you want to know the CPU speed of a centrino. And any idea how you can get the correct one? Thanx.
|
|
|
|
|
Hi all,
I am a student, at Staffordshire University, UK, my
area of interest is mobile agent at wireless environment (mobile
computing). I would like to ask whether you have any information how
to use MATLAB tools to simulate a mobile computing system. In other
words, I want to build a wireless system (client/server) where data(an object user-defined) can be sent between mobile terminal and a server in order to carry out some tasks at the server and return with some results.
Any help would be appreciated
Regards,
Adel
|
|
|
|
|
In SysInfoDefs.h line 131 you miss a comma after (S.M.A.R.T.)"
...Plug & Pray...
|
|
|
|
|
You are right. Thanks for your comment.
A. Riazi
|
|
|
|
|
Nice Job BTW. It is quite usefull to me.
I thing that it whould be quite handy if it could export the results is some file (text, xml or anything).
...Plug & Pray...
|
|
|
|
|
I will do it in next update.
A. Riazi
|
|
|
|
|
hi !
How can i modify your code to retrieve hardware info about removable disks like USB disks ? is there an API available for that ?
thx
Kane
"Some guys hack just to get themselves a girkfriend.What a pathetic reason huh ? "
|
|
|
|
|
|
Hello folks.
I downloaded the example, installed the latest platform sdk for Windows 2000 and I have service pack 6 installed for Visual Studio. Unfortunately I'm still getting compile errors. I've read through all of the board messages for hints but I still can't get it working. Any help would be appreciated.
For Instance:
SysInfoDefs.cpp(695) : error C2065: 'DRIVE_LAYOUT_INFORMATION_EX' : undeclared identifier
And also:
SysInfoDlg.cpp(305) : error C2065: 'CSIDL_WINDOWS' : undeclared identifier
Jeff
|
|
|
|