#include "StdAfx.h"
#include "MPosLookup.h"

CMPosLookup::CMPosLookup()
{
	LoadDll();
}

CMPosLookup::~CMPosLookup()
{
	UnloadDll();
}

void CMPosLookup::UnloadDll()
{
	FreeLibrary(m_hDll);
	m_hDll = NULL;
}

bool CMPosLookup::LoadDll()
{ 	
	m_hDll = LoadLibrary(_T("MPosLookup.dll"));

	int res = GetLastError();

	if(m_hDll == 0)
		return FALSE;

	fgetNetworkDevices		= (pGetNetworkDevices)GetProcAddress(m_hDll, "getNetworkDevices");
	fgetBluetoothDevices	= (pGetBluetoothDevices)GetProcAddress(m_hDll, "getBluetoothDevices");
	fgetUSBDevices			= (pGetUSBDevices)GetProcAddress(m_hDll, "getUSBDevices");
	fgetSerialDevices		= (pGetSerialDevices)GetProcAddress(m_hDll, "getSerialDevices");
	fgetParallelDevices		= (pGetParallelDevices)GetProcAddress(m_hDll, "getParallelDevices");

	return TRUE;
}

LPCWSTR CMPosLookup::getNetworkDevices()
{
	return fgetNetworkDevices();
}

LPCWSTR CMPosLookup::getBluetoothDevices()
{
	return fgetBluetoothDevices();
}

LPCWSTR CMPosLookup::getUSBDevices()
{
	return fgetUSBDevices();
}

LPCWSTR CMPosLookup::getSerialDevices()
{
	return fgetSerialDevices();
}

LPCWSTR CMPosLookup::getParallelDevices()
{
	return fgetParallelDevices();
}