|
I searched a long time for that.. especially to read the temperature of the hdd !
thank you
|
|
|
|
|
Good luck with your project..
Saneesh
Saneesh
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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 !
|
|
|
|
|
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
|
|
|
|
|
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!
|
|
|
|
|
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
|
|
|
|
|
I need to write a simple console app. in c++ to interogate the HDD temperature sensor (via SMART). Can anybody give me some pointers on line/s of code needed to accomplish that and what #includes are needed.
|
|
|
|
|
You can use this code and then use only the hard drive temperature information from this one. It is pretty simple. Download the code and check it.
Saneesh
|
|
|
|
|
Your code is too involved for me to simply reverse engineer like that. I presume there are a couple of #includes followed by a function call to activate SMART then retrieve data from it. What call/function should I be looking for??
|
|
|
|
|
You need to look into the class named CSmartReader (SmartReader.cpp). Follow steps as below.
1) Create an object of class CSmartReader say oSmartReader
2) Call oSmartReader.ReadSMARTValuesForAllDrives()
3) Now assuming that you have only one hard drive
pDriveInfo=m_oSmartReader.GetDriveInfo(0);
pSmartInfo=m_oSmartReader.GetSMARTValue(pDriveInfo->m_ucDriveIndex,194);
pSmartInfo->m_ucValue will give you the temperature.
Thanks,
Saneesh
Saneesh
|
|
|
|
|
Nice one Saneesh...
BesRegs
|
|
|
|
|
Saneesh,
Your original research material for smart reader project, is it available on the net?
BesRegs
|
|
|
|
|
Not as whole. I collected it from various sites.
Saneesh
|
|
|
|
|
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
SMART.cpp
c:\tddownload\smart\smartreader.h(13) : fatal error C1083: Cannot open include file: 'devioctl.h': No such file or directory
SMARTDlg.cpp
c:\tddownload\smart\smartreader.h(13) : fatal error C1083: Cannot open include file: 'devioctl.h': No such file or directory
SmartReader.cpp
c:\tddownload\smart\smartreader.h(13) : fatal error C1083: Cannot open include file: 'devioctl.h': No such file or directory
Generating Code...
Error executing cl.exe.
SMART.exe - 3 error(s), 0 warning(s)
www
|
|
|
|
|
Include the "DDKInclude" path in "Include files" option in VC's setting or change starting of the smartreader.h as below..
#if !defined(AFX_SMARTREADER_H__494F15B9_0FFA_4BB4_BDD0_2D4C5129E530__INCLUDED_)
#define AFX_SMARTREADER_H__494F15B9_0FFA_4BB4_BDD0_2D4C5129E530__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _WIN32_WINNT 0x500
#include "DDKInclude\\devioctl.h"
#include "DDKInclude\\ntdddisk.h"
Saneesh
|
|
|
|
|
Hi there,
I tested the programm under Winxp as a normal user without adminrights.
The result is an empty list.
Im quite new to the topic so my question is whether its because of the missing rights.
thx in Advance
|
|
|
|
|
Can you check the reply from the DeviceIOControl function and also other API's? If it is failing, use GetLastError and see if it is privilege related issue.
Good luck
Saneesh
Saneesh
|
|
|
|
|
:(My Code is running normally in XP system, but it cannot detect any infotmation in Vista, it seems the funcion can not be supported by Vista system. There is any another way to use SMART Function in Vista? Thanks a lot!
Mywork_007
|
|
|
|
|
Hi,
The problem in Vista is because of strict user permission (as far as i could understand). The command is should be supported by device driver for the hard drive. Once i figure out how to do it, i will update it on CP. Thanks
for looking at it. Don't know any other way to do it. Actually i never gets that much time on Vista.
Thanks,
Saneesh
Saneesh
|
|
|
|
|
Hi, Thanks for your reply.
I have run my program as administrator, so i think is not user permission issue. and i have use the Function(GetLastError())to get the errorcode, it return 50. I will still trace this issue. Thanks a lot!
Mywork_007
|
|
|
|
|
Please let me know if you can make it work in Vista. I could not even make a successful call to CreateFile because of permission issue.
Saneesh
Saneesh
|
|
|
|
|
sorry, I can not make it work in Vista due to the DeviceIoControl Fialed.
But the CreateFile Function is successed in Vista. For Permission issue, you can set UAC in control panel or ren the executable file to the name which contain the character "Install" or "setup" to improve the access rights.
Also I can not find the description of the IOCTL code(SMART_GET_VERSION) in the latest WDK documentation for Vista, but I can find it in before version what used for XP. so it seems this function is not supported by Visat yet, but there have not any indication to tell us whether there have another way to solve this.
Thanks a lot!
Mywork_007
|
|
|
|