 |
|
 |
Hossam,
Have you been able to come up with a solution for either Vista or 7?
Thanks
|
|
|
|
 |
|
 |
No, i am waiting for the miracle :/
|
|
|
|
 |
|
 |
Try to run as administator. Valery.
|
|
|
|
 |
|
 |
I've tried to build your source under VS2008 but i get lots of build errors with the DriveInfoEx.dll.
Many 'struct' type redefinition errors.
|
|
|
|
 |
|
 |
I ran into the same errors, but there is an easy fix. The problem is that some of the structures have already been defined in VS2008 (winioctl.h). You just need to remove or comment out those structures in UnmanagedCode.h. This is how my UnmanagedCode.h looks like afterwards:
#pragma once
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <windows.h>
#include <winioctl.h>
#pragma warning(disable:4996)
#pragma pack(1)
#define IDENTIFY_BUFFER_SIZE 512
#define DFP_GET_VERSION 0x00074080
#define DFP_SEND_DRIVE_COMMAND 0x0007c084
#define DFP_RECEIVE_DRIVE_DATA 0x0007c088
#define FILE_DEVICE_SCSI 0x0000001b
#define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501)
#define IOCTL_SCSI_MINIPORT 0x0004D008
#define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
#define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
typedef struct _GETVERSIONOUTPARAMS
{
BYTE bVersion; BYTE bRevision; BYTE bReserved; BYTE bIDEDeviceMap; DWORD fCapabilities; DWORD dwReserved[4]; } GETVERSIONOUTPARAMS, *PGETVERSIONOUTPARAMS, *LPGETVERSIONOUTPARAMS;
#define CAP_IDE_ID_FUNCTION 1 #define CAP_IDE_ATAPI_ID 2 #define CAP_IDE_EXECUTE_SMART_FUNCTION 4
#define IDE_ATAPI_IDENTIFY 0xA1 #define IDE_ATA_IDENTIFY 0xEC
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(1)
typedef struct _IDENTIFY_DATA {
USHORT GeneralConfiguration; USHORT NumberOfCylinders; USHORT Reserved1; USHORT NumberOfHeads; USHORT UnformattedBytesPerTrack; USHORT UnformattedBytesPerSector; USHORT SectorsPerTrack; USHORT VendorUnique1[3]; USHORT SerialNumber[10]; USHORT BufferType; USHORT BufferSectorSize; USHORT NumberOfEccBytes; USHORT FirmwareRevision[4]; USHORT ModelNumber[20]; UCHAR MaximumBlockTransfer; UCHAR VendorUnique2; USHORT DoubleWordIo; USHORT Capabilities; USHORT Reserved2; UCHAR VendorUnique3; UCHAR PioCycleTimingMode; UCHAR VendorUnique4; UCHAR DmaCycleTimingMode; USHORT TranslationFieldsValid:1; USHORT Reserved3:15;
USHORT NumberOfCurrentCylinders; USHORT NumberOfCurrentHeads; USHORT CurrentSectorsPerTrack; ULONG CurrentSectorCapacity; USHORT CurrentMultiSectorSetting; ULONG UserAddressableSectors; USHORT SingleWordDMASupport : 8; USHORT SingleWordDMAActive : 8;
USHORT MultiWordDMASupport : 8; USHORT MultiWordDMAActive : 8;
USHORT AdvancedPIOModes : 8; USHORT Reserved4 : 8;
USHORT MinimumMWXferCycleTime; USHORT RecommendedMWXferCycleTime; USHORT MinimumPIOCycleTime; USHORT MinimumPIOCycleTimeIORDY; USHORT Reserved5[2]; USHORT ReleaseTimeOverlapped; USHORT ReleaseTimeServiceCommand; USHORT MajorRevision; USHORT MinorRevision; USHORT Reserved6[50]; USHORT SpecialFunctionsEnabled; USHORT Reserved7[128]; } IDENTIFY_DATA, *PIDENTIFY_DATA;
#pragma pack()
typedef struct _SRB_IO_CONTROL
{
ULONG HeaderLength;
UCHAR Signature[8];
ULONG Timeout;
ULONG ControlCode;
ULONG ReturnCode;
ULONG Length;
} SRB_IO_CONTROL, *PSRB_IO_CONTROL;
#define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#ifndef NATIVE_CODE
using namespace System;
#endif
#include <vector>
using namespace std ;
typedef vector<WORD*> LISTDATA;
#define MAX_IDE_DRIVES 16
class DiskInfo
{
static DiskInfo* m_instance;
static char HardDriveSerialNumber [1024];
LISTDATA m_list;
public:
static DiskInfo& GetDiskInfo()
{
if(m_instance == NULL)
m_instance = new DiskInfo();
return *m_instance;
};
static void Destroy()
{
if(m_instance != NULL)
delete m_instance;
m_instance = NULL;
};
~DiskInfo(void);
int ReadIdeDriveAsScsiDriveInNT (void);
long LoadDiskInfo ();
int ReadPhysicalDriveInNTWithAdminRights (void);
int ReadPhysicalDriveInNTWithZeroRights (void);
int ReadDrivePortsInWin9X (void);
int ReadPhysicalDriveInNTUsingSmart (void);
unsigned __int64 DriveSize (UINT drive);
UINT GetCount (){return m_list.size();};
UINT BufferSize (UINT drive);
#ifndef NATIVE_CODE
String^ GetModelNumber (UINT drive);
String^ GetSerialNumber(UINT drive);
String^ GetRevisionNumber (UINT drive);
String^ GetDriveType (UINT drive);
#else
char* ModelNumber (UINT drive);
char* SerialNumber (UINT drive);
char* RevisionNumber (UINT drive);
char* DriveType (UINT drive);
#endif
private:
DiskInfo(void);
static char * flipAndCodeBytes (char * str);
static char * ConvertToString (WORD diskdata [256], int firstIndex, int lastIndex);
static BOOL DoIDENTIFY (HANDLE hPhysicalDriveIOCTL, PSENDCMDINPARAMS pSCIP,
PSENDCMDOUTPARAMS pSCOP, BYTE bIDCmd, BYTE bDriveNum,
PDWORD lpcbBytesReturned);
BOOL AddIfNew(USHORT *pIdSector);
#ifndef NATIVE_CODE
String^ GetString (WORD* pdiskdata, int firstIndex, int lastIndex);
#endif
};
|
|
|
|
 |
|
 |
Thanks for the code examples!!! Love your avatar! "Drop the catnip and spread em"
The grass IS greener on the other side!
|
|
|
|
 |
|
 |
Hi
Thanks for this
but I an having issue while installing on computer where .Net is not installed.
I have installed following
2.0 Framwork is installed
c++ 2008 redistributed package is also installed
is there anything missed ??
Thanks in advance
Plz reply
|
|
|
|
 |
|
 |
I've built it with VS 2005.
Unless you've rebuilt it with VC++ 2008, you'll need c++ 2005 redistributable instead of 2008.
|
|
|
|
 |
|
 |
when Administrator rights is not given, it is not working for web application in windows server 2003 and vista. So is there any other method to get the HDD manufacturer serial no without admin rights?
|
|
|
|
 |
|
 |
Whether DriveInfoEx.dll supports Windows Server 2008?
Regards,
Christopher
|
|
|
|
 |
|
 |
I don't know. I haven't tested on anyting but Windows XP.
|
|
|
|
 |
|
 |
Whether DriveInfoEx.dll supports Microsoft Win 64 bit machines?
Regards,
Christopher
|
|
|
|
 |
|
 |
I don't know. I haven't tested on anyting but Windows XP 32 bit.
If you change the include and lib paths to 64 bits file in the cpp project, I assume it might work.
|
|
|
|
 |
|
 |
It doesn't work on xp x64, DeviceIoControl fails on DFP_GET_VERSION request.
Any ideas why?
Thank you
|
|
|
|
 |
|
 |
are you sure you use the 64 bit include files and 64 bit libs when compiling (under options I think)?
|
|
|
|
 |
|
 |
Yes, compile it with 64 bit. The thing is i've done some tests with in vmware workstation and basically it will not get the drive info if the hdd is scsi, I think it has to do with vmware hardware emulation stuff, and i'm sure of that because I've done non vmware test in xp,vista, win 7 (with and without admin rights) and everything works as expected.
Thanks again for the article and your continuous support
|
|
|
|
 |
|
 |
Can you give some information about how to compile DriveInfoEx.dll with 64 bit.?
|
|
|
|
 |
|
 |
Set the include and Libs paths to the 64 bit under options.
Also check if the win32 apis I used have some 64 bit variant.
|
|
|
|
 |
|
 |
Please provide the details of Hard Disk Interface types compatibility with DriveInfoEx.dll
Regards,
Christopher
|
|
|
|
 |
|
|
 |
|
 |
Please provide the list of Hard Disk Manufacturers compatibilty with DriveInfoEx.dll
Regards,
Christopher
|
|
|
|
 |
|
 |
I've tested only on WD and Maxtor.
|
|
|
|
 |
|
 |
How to set administrator rights for IIS (web application asp.net 2.0) which had the reference of DriveInfoEx.dll to run in windows server 2003 and windows vista business edition ?
Kindly give me inputs.
Regards,
Christopher.
|
|
|
|
 |
|
 |
Hello sir,
Will you please update this for VS2008?
So, can able to use it with Visual Studio 2008... Or please provide help to use it with VS2008. It shows so many compilation errors with VS2008...
Thanks!!!
|
|
|
|
 |
|
|
 |