
#pragma once

#include <windows.h>
#include "stdafx.h"
#include <winsvc.h>
#include <setupapi.h>
#include <devguid.h>
#include <regstr.h>

//Error codes

#define DEV_OK (DWORD)0
#define DEV_NOT_CREATE (DWORD)1
#define DEV_NOT_START (DWORD)2
#define DEV_NOT_INIT (DWORD)3
#define DEV_ERROR_SCMANAGER (DWORD)4
#define DEV_ERROR_CREATE (DWORD)5
#define DEV_ERROR_START (DWORD)6
#define DEV_ERROR_OPEN (DWORD) 7
#define DEV_ERROR_STOP (DWORD)8
#define DEV_ERROR_UNLOAD (DWORD) 9


#define DEVICE_FIRST_SLOT	"device 15"
#define DEVICE_SECOND_SLOT	"device 14"

#define DeviceDesc_AtherosWiFi TEXT("Atheros AR922X Wireless Network Adapter")

#define DebugPrint(BOOL,STRING) \
	if(BOOL)\
	{\
	printf STRING;\
	}\

#define DebugPrintW(BOOL,STRING) \
	if(BOOL)\
	{\
	wprintf STRING;\
	}\


class CDeviceDetection
{
public:
	//Constructor
	CDeviceDetection(void);
	CDeviceDetection(PCSTR _pEnumerator,DWORD _Property,LPTSTR _CompareString);

	//Destructor
	~CDeviceDetection(void);
	
	//device detection functions
	DWORD		InitParam(PCSTR _pEnumerator,DWORD _Property,LPTSTR _CompareString);
	void		SearchDevices(); //void	SearchDevices(PCSTR pEnumerator,DWORD Property,IN LPTSTR CompareString);
	void		EnumDevices(HDEVINFO ,PSP_DEVINFO_DATA,DWORD ,IN LPTSTR );
	void		CloseDeviceInfo();
	int			ErrorHandle();
	HDEVINFO	CreateDeviceInfo(PCSTR pEnumerator);
	BOOL		IsInit(void); //check if service is init
	BOOL		IsDeviceFound(void); //check if device is found

private:
	PCSTR		pEnumerator;
	DWORD		Property;
	LPTSTR		CompareString;

	HDEVINFO	hDevInfo;	  //device info	
	BOOL		devicefound;  //device status
	BOOL		init; 

};
