 |
|
|
 |
|
|
 |
|
|
 |
|
 |
How can read the S.R.A.R.T information with C# language? Anybody can provide some methods for me.thanks!
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
You can export the deviceiocontrol and other relevant functions as below.
[DllImport("xxxx.dll")] public static extern fnType fnName ( Params );
With this, you can call and execute the code from C#
Saneesh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks Saneesh! You mean i can use the dll that was build by C++, is that right? But i just want to known how can i only use the C# language to build a dll and use it. Can you give me some advice about this?
|
| Sign In·View Thread·PermaLink | 3.00/5 (1 vote) |
|
|
|
 |
|
 |
Did anyone had any luck with using this program to monitor SMART params for HDDs that are connected through SCSI? It is giving device I/O errors. Any help is appreciated.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Saneesh, DeviceIoControl control returns the error code 1117 which is error code for I/O device error.
Regards, Sukhas
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
Hello,
i have some probs on my laptop and desktop pc...both xp machines..
all the threshhold values are 0....smartmontools and hddlife is getting other and i think correct threshold values ?
any idea how to get the right ones
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Did you tried to debug and see if the buffer is getting values properly? Also the .ini file, is that in the executable / debug path? Without that the code wont work.
Saneesh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thx 4 this fine code! 
but, a small bug is fixed.
first: My threshold is always 0, but HD-Tune has some values!
I fix this:
stCIP.irDriveRegs.bFeaturesReg=READ_THRESHOLDS; stCIP.cBufferSize=READ_THRESHOLD_BUFFER_SIZE; bRet=DeviceIoControl(hDevice,SMART_RCV_DRIVE_DATA,&stCIP,sizeof(stCIP),szAttributes,sizeof(ST_ATAOUTPARAM) + READ_ATTRIBUTE_BUFFER_SIZE - 1,&dwRet,NULL); if(bRet) { pT1=(PBYTE)(((ST_ATAOUTPARAM*)szAttributes)->bBuffer); for(ucT1=0;ucT1<30;++ucT1) { pT2=(PDWORD)&pT1[2+ucT1*12+5];
to
stCIP.irDriveRegs.bFeaturesReg=READ_THRESHOLDS; stCIP.cBufferSize=READ_THRESHOLD_BUFFER_SIZE; bRet=DeviceIoControl(hDevice,SMART_RCV_DRIVE_DATA,&stCIP,sizeof(stCIP),szAttributes,sizeof(ST_ATAOUTPARAM) + READ_ATTRIBUTE_BUFFER_SIZE - 1,&dwRet,NULL); if(bRet) { pT1=(PBYTE)(((ST_ATAOUTPARAM*)szAttributes)->bBuffer); for(ucT1=0;ucT1<30;++ucT1) { pT2=(PDWORD)&pT1[2+ucT1*12+1];
+5 is 4 bytes after usable threshold data.
second: Some RAW data is truncated, see HD-Tune or smartmontools at many hd drives. i fix all of this (at 2 positions):
pT3[INDEX_ATTRIB_RAW+2]=pT3[INDEX_ATTRIB_RAW+3]=pT3[INDEX_ATTRIB_RAW+4]=pT3[INDEX_ATTRIB_RAW+5]=pT3[INDEX_ATTRIB_RAW+6]=0;
to
pT3[INDEX_ATTRIB_RAW+4]=pT3[INDEX_ATTRIB_RAW+5]=pT3[INDEX_ATTRIB_RAW+6]=0;
pT3[INDEX_ATTRIB_RAW+2]=pT3[INDEX_ATTRIB_RAW+3]=0 kills high word from data.
Now works fine for me, all data like hd-tune and smartmontools!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
hi, i would like to ask how can i get the partition or size of the disk since the demo code cant get it if i nt mistaken?
hope to hear u soon. thanks.
regards warr~~en
modified on Friday, June 20, 2008 5:17 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
The code here is only to get the SMART parameters from the HDD and not the partition information. How ever the information for partition is stored in sector 0 of the hard drive ( that's what i remember). There are some fixed structures also on how each record is defined with type, size, name etc. I think i saw this in the code project it self. If you can not find it in the code project, let me know. Once i get time, i will upload it as a new article in code project.
Thanks, Saneesh
Saneesh
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi, i think i figured out how to get the size of the size... if i still cannot solve then i will come here and trouble you again... haha...
anyway, thanks a lot for your code and this reply... thanks...
regards warr~~en
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have been struggling with the smart interface for some time now, though C++ isnt a specialty of mine I stumbled upon a bit of a problem. I have no problem reading info from my own harddrives but when i try reading smart info from the HDD's of one of our servers I get nothing but a blanc screen.
Now my guesse is my drives are just not detected, but why? For all i know they're all SMART enabled. Is there some kind of conflict with the fact that its on SCSI or a RAID configuration?
it's a nice bit of code though nicely done Hope to hear from you soon !
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
Did you put the SMART.ini in the same folder as SMART.exe? If so please do it and try again.
If it still does not show any information, you have to debug the code / put some message boxes in the code and compile it. It should detect the drives. If the OS can see it, this one should also see it.
Good luck! Saneesh
Saneesh
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi: I am from Taiwan ,and would like to read/write HDD Device,my question is 1. which control code will I select when I using DeviceIoControl()?IOCTL_ATA_PASS_THROUGH or others? 2. How can I fill the InBuffer and OutBuffer? if use the ATA_PASS_THROUGH_EX structure ,or exists other data structure? 3.if it's ok? can you show me an example just modify your demo project ?
since I cannot get your e-mail account ? if it's fine can you show me your contact e-mail?
and my e-mail is: johnnyhuang@itri.org.tw
I AM LOOK FORWARD FOR youe kindly reply!
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
 |
Hi,
I have not tried writing / reading directly to/from sectors. Basically the In and out buffer for the DeviceIOControl is the exact buffer size needed to perform the command specified. So the size of the buffer will be different for different IOCTL's.
I remember seeing some code to read CD sectors in the code project. It should have the sample code and you can modify it. Most of these are standardised code so that device driver + firmware should support it.
Some sample code and it is from code project.
bool DiskSectorWinNT::Open(char *vol) { char szDrive[10]; sprintf(szDrive, "\\\\.\\%c:", vol[0]); m_hDisk = ::CreateFile( szDrive, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); return m_hDisk != INVALID_HANDLE_VALUE; }
void DiskSectorWinNT::Close() { if (m_hDisk != INVALID_HANDLE_VALUE) ::CloseHandle(m_hDisk); }
bool DiskSectorWinNT::ReadSector (DWORD sector, char *Buffer, int sectorSize) { DWORD read = 0;
if (::SetFilePointer(m_hDisk, sector, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) return false;
if (!::ReadFile(m_hDisk, Buffer, sectorSize, &read, NULL)) return false; return true; }
bool DiskSectorWinNT::WriteSector(DWORD sector, char *Buffer, int sectorSize) { DWORD wrote = 0; if (::SetFilePointer(m_hDisk, sector, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) return false;
if (!::WriteFile(m_hDisk, Buffer, sectorSize, &wrote, NULL)) return false;
return true; }
Thanks, Saneesh
Saneesh
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |