
#define _WIN32_DCOM
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>

# pragma comment(lib, "wbemuuid.lib")


class List {
 public:
	 int no;
	 char name[128];
};


/*****************************************************************************
 *  Self-defined definition													*
 ****************************************************************************/
#define WMI_FOUND_PNPDEVICEID			0
#define	WMI_NO_MATCHED_DRIVE_LETTER		1
#define WMI_NO_MATCHED_PHYSICAL_NAME	2
#define WMI_NO_MATCHED_PNPDEVICEID		3

/*****************************************************************************
 *  Self-defined function declaration section								*
 ****************************************************************************/

/*	
 *	Description:
 *		Compare if drive letter and physical location is matched
 *
 *	Input:		
 *		<szName> : request name of wmi
 *
 *	Output:
 *		<szResult> : result of wmi strings
 *		<numOfResult> : number of string return
 *
 *	Return:
 *		TRUE indicates success, FALSE indicates fail.
 */
int wmi_get_value_by_name(char *szClassName,WCHAR *szPropertyName,BOOL bISInteger,vector<List> &szResult,int *numOfResult);

//BOOL GetLogicDiskToPartitionInfo();
BOOL WMIGetLogicDiskToPartitionInfo(vector<List> &szAntecedentLogicalDiskToPartition,vector<List> &szDependentLogicalDiskToPartition);

//BOOL GetDiskDriveToDiskPartitionInfo();
BOOL WMIGetDiskDriveToDiskPartitionInfo(vector<List> &szAnteDiskDriveToDiskPart,vector<List> &szDepDiskDriveToDiskPart);

//BOOL GetDiskDriveInfo();
BOOL WMIGetDiskDriveInfo(vector<List> &szDeviceIDDiskDrive,vector<List> &szPNPDeviceID);

BOOL WMIGetDiskDriveInfo2(vector<List> &szDeviceIDDiskDrive,vector<List> &szSCSIPort);

BOOL WMIGetDiskDriveInfoByName(WCHAR *firstItemName, WCHAR *secondItemName, vector<List> &szFirstItem, vector<List> &szSecondItem);

BOOL WMIGetSCSIBusNumber(TCHAR *szDriveLetter,int *nSCSIBusNumber);

BOOL WMIGetSCSIPort(TCHAR *szDriveLetter,int *nSCSIPort);

BOOL WMIGetSCSIPortInfo(vector<List> &szSCSIPort);

/*	
 *	Description:
 *		Get PNPDeviceID of specified drive
 *
 *	Input:		
 *		<szRawDriveLetter> : drive letter of a volume. Ex. "D:\"
 *
 *	Output:
 *		<szPNPDeviceID> : drive letter of a volume. Ex. "0 or 2..."
 *
 *	Return:
 *		0 indicates found matehed PNPDeviceID
 *		1 indicates no matched drive letter
 *		2 indicates no matched physical name
 *		3 indicates no matched PNPDeviceID
 */
BOOL WMIGetPNPDeviceID(TCHAR *szDriveLetter,TCHAR *szPNPDeviceID);

int WMIGetPhysicalDiskName(TCHAR *szRawDriveLetter,TCHAR *szPhysicalDiskName);