V
haste inzwischen erfolg gehabt? ich steh diesbezüglich auch grad in ner undokumentierten wüste.
edit: falls es hilft, hab ein paar sachen zusammenkopiert, die aber gar nicht so klappen. vielleicht aber als stichwortgeber:
#include <iostream>
#include <windows.h>
//#include <winioctl.h>
#include <ddk/ntdddisk.h>
using namespace std;
void test()
{
HANDLE hDevice=CreateFile("\\\\.\\PhysicalDrive0", // drive to open
0, // no access to the drive
FILE_SHARE_READ| // share mode
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
if(hDevice==INVALID_HANDLE_VALUE) // cannot open the drive
{
throw "cant open device";
}
SENDCMDINPARAMS* scip=reinterpret_cast<SENDCMDINPARAMS*>(operator new(1024));
scip->cBufferSize=512;
scip->irDriveRegs.bCommandReg=SMART_CMD;
scip->irDriveRegs.bFeaturesReg=RETURN_SMART_STATUS|READ_ATTRIBUTES;
scip->bDriveNumber=0;
scip->bBuffer[0]=231;
SENDCMDOUTPARAMS* scop=reinterpret_cast<SENDCMDOUTPARAMS*>(operator new(1024));
DISK_GEOMETRY pdg;
DWORD junk;
bool rc=DeviceIoControl(hDevice, // device to be queried
SMART_RCV_DRIVE_DATA, // operation to perform
scip,512, // no input buffer
scop,512, // output buffer
&junk, // # bytes returned
(LPOVERLAPPED) NULL); // synchronous I/O
if(!rc)
cout<<"error: "<<GetLastError()<<endl;//hier kommt fehler 5
cout<<"scopds "<<scop->DriverStatus.bDriverError<<endl;
cout<<"scopbu "<<scop->bBuffer<<endl;
CloseHandle(hDevice);
}
int main()
{
test();
return 0;
}
edit2: und wenn jetzt jemand sagt, der würde keine sachen auslesen, weil delete fehlt, dann hab ich das schon erwartet.
[ Dieser Beitrag wurde am 13.05.2003 um 03:49 Uhr von volkard editiert. ]