Skip to main content

Posts

Showing posts from March, 2013

Physical Disk (HDD) Adapter Information.

In my previous post, I tried to build a command line app to show Physical Hard drives and volume(s) mapping for each HDD present/attached to a system. Now I've extended the program to read and display the properties of the storage adapter for each physical hard drive. To achieve this I've used the very popular Win32 API, CreateFile(), and IOCTL_STORAGE_QUERY_PROPERTY control code. The previous program has been extended and now I'm showing only the part I've added on top of my previous program released under the title "PhysicalDisk and Volume Mapping information". Here goes the rest of the code to get the storage adapter's information: void PrintBusTypeName(BYTE iBusType) {     switch(iBusType)     {     case BusTypeUnknown:         wprintf(L"BusType: Unknown\n");         break;     case BusTypeScsi:         wprintf(L"BusType: SCSI\n");         break;     case BusTypeAtapi:         wprintf(L"BusType: ATAPI\n");         br

PhysicalDisk and Volume Mapping information

After a long time, writing this post on Windows Disk Management. I was playing with volume management APIs and found it's quite easy to get some useful information like, how I know what are the volume(s) present on a physical disk. I'm talking about a hard drive here. Of course, the Windows disk manager will reveal it but why not I should have my own app. There are Windows Volume Management APIs including the very famous CreateFile API, which is one of the amazing APIs on Windows provided by Microsoft. The objective was to build a tool that will tell How many HDDs are attached to the system with volume information. Here is the complete code: const int BUFF_SIZE           = 512; const int STR_SIZE              = 20; const int DRIVE_ID_BUFF = 3; int _tmain(int argc, _TCHAR* argv[]) {     TCHAR szTemp[BUFF_SIZE];         if (GetLogicalDriveStrings(BUFF_SIZE - 1, szTemp))     {         TCHAR szDrive[DRIVE_ID_BUFF] = TEXT(" :");         TCHAR* pDrive = szTemp;