#include "stdafx.h"
#include "PrinterBase.h"

/////////////////////////////////////
//define 
////////////////////////////////////

PrtFormatErrorA									FormatErrorA;
PrtFormatErrorW									FormatErrorW;
PrtPrinterCreatorA								PrinterCreatorA;
PrtPrinterCreatorW								PrinterCreatorW;
PrtPortOpenA									PortOpenA;
PrtPortOpenW									PortOpenW;
PrtPortClose									PortClose;
PrtPrinterDestroy								PrinterDestroy;
PrtPrinterInitialize							PrinterInitialize;
PrtCutPaper										CutPaper;
PrtPrintTextA									PrintTextA;
PrtPrintTextW									PrintTextW;
PrtFeedLine										FeedLine;
PrtPrintBarCodeA								PrintBarCodeA;
PrtPrintBarCodeW								PrintBarCodeW;
PrtPrintSymbolA									PrintSymbolA;
PrtPrintSymbolW									PrintSymbolW;
PrtPrintImageA									PrintImageA;
PrtPrintImageW									PrintImageW;
PrtDefineNVImageCompatibleA						DefineNVImageCompatibleA;
PrtDefineNVImageCompatibleW						DefineNVImageCompatibleW;
PrtPrintNVImageCompatible						PrintNVImageCompatible;

PrtDefineNVImageA								DefineNVImageA;
PrtDefineNVImageW								DefineNVImageW;
PrtPrintNVImage									PrintNVImage;
PrtDefineBufferedImageA							DefineBufferedImageA;
PrtDefineBufferedImageW							DefineBufferedImageW;
PrtPrintBufferedImage							PrintBufferedImage;
PrtDefineDownloadedImageCompatibleA				DefineDownloadedImageCompatibleA;
PrtDefineDownloadedImageCompatibleW				DefineDownloadedImageCompatibleW;
PrtPrintDownloadedImageCompatible				PrintDownloadedImageCompatible;

PrtOpenDrawer									OpenDrawer;
PrtSelectStandardMode							SelectStandardMode;
PrtSetTextLineSpace								SetTextLineSpace;
PrtSetTextPosition								SetTextPosition;
PrtSelectPageMode								SelectPageMode;
PrtSetPrintAreaInPageMode						SetPrintAreaInPageMode;
PrtSelectPrintDirectionInPageMode				SelectPrintDirectionInPageMode;
PrtSetAbsolutePrintPosition						SetAbsolutePrintPosition;
PrtSetAbsoluteVerticalPrintPositionInPageMode	SetAbsoluteVerticalPrintPositionInPageMode;
PrtPrintAndReturnStandardMode					PrintAndReturnStandardMode;
PrtPrintDataInPageMode							PrintDataInPageMode;
PrtCheckPrinterState							CheckPrinterState;
PrtDirectIO										DirectIO;
PrtSetCharacterSet								SetCharacterSet;
PrtGetPrinterVersion							GetPrinterVersion;
PrtPositionNextLabel							PositionNextLabel;

void*			hprinter;
HMODULE			m_hDll;

void UnloadDll()
{
	FreeLibrary(m_hDll);
}

BOOL LoadDll()
{
	m_hDll = LoadLibrary(_T("ESC_SDK.dll"));	

	if(m_hDll == 0)
		return FALSE;

	FormatErrorA = (PrtFormatErrorA)GetProcAddress(m_hDll, "PrtFormatErrorA");
	FormatErrorW = (PrtFormatErrorW)GetProcAddress(m_hDll, "PrtFormatErrorW");
	PrinterCreatorA = (PrtPrinterCreatorA)GetProcAddress(m_hDll, "PrtPrinterCreatorA");
	PrinterCreatorW = (PrtPrinterCreatorW)GetProcAddress(m_hDll, "PrtPrinterCreatorW");

	PrinterInitialize = (PrtPrinterInitialize)GetProcAddress(m_hDll, "PrtPrinterInitialize");
	PortOpenA = (PrtPortOpenA)GetProcAddress(m_hDll, "PrtPortOpenA");
	PortOpenW = (PrtPortOpenW)GetProcAddress(m_hDll, "PrtPortOpenW");
	PortClose = (PrtPortClose)GetProcAddress(m_hDll, "PrtPortClose");
	PrinterDestroy = (PrtPrinterDestroy)GetProcAddress(m_hDll, "PrtPrinterDestroy");

	CutPaper = (PrtCutPaper)GetProcAddress(m_hDll, "PrtCutPaper");
	PrintTextA = (PrtPrintTextA)GetProcAddress(m_hDll, "PrtPrintTextA");
	PrintTextW = (PrtPrintTextW)GetProcAddress(m_hDll, "PrtPrintTextW");
	FeedLine = (PrtFeedLine)GetProcAddress(m_hDll, "PrtFeedLine");
	PrintBarCodeA = (PrtPrintBarCodeA)GetProcAddress(m_hDll, "PrtPrintBarCodeA");
	PrintBarCodeW = (PrtPrintBarCodeW)GetProcAddress(m_hDll, "PrtPrintBarCodeW");
	PrintSymbolA = (PrtPrintSymbolA)GetProcAddress(m_hDll, "PrtPrintSymbolA");
	PrintSymbolW = (PrtPrintSymbolW)GetProcAddress(m_hDll, "PrtPrintSymbolW");
	PrintImageA = (PrtPrintImageA)GetProcAddress(m_hDll, "PrtPrintImageA");
	PrintImageW = (PrtPrintImageW)GetProcAddress(m_hDll, "PrtPrintImageW");
	DefineNVImageCompatibleA = (PrtDefineNVImageCompatibleA)GetProcAddress(m_hDll, "PrtDefineNVImageCompatibleA");
	DefineNVImageCompatibleW = (PrtDefineNVImageCompatibleW)GetProcAddress(m_hDll, "PrtDefineNVImageCompatibleW");
	PrintNVImageCompatible = (PrtPrintNVImageCompatible)GetProcAddress(m_hDll, "PrtPrintNVImageCompatible");

	DefineNVImageA = (PrtDefineNVImageA)GetProcAddress(m_hDll, "PrtDefineNVImageA");
	DefineNVImageW = (PrtDefineNVImageW)GetProcAddress(m_hDll, "PrtDefineNVImageW");
	PrintNVImage = (PrtPrintNVImage)GetProcAddress(m_hDll, "PrtPrintNVImage");
	DefineBufferedImageA = (PrtDefineBufferedImageA)GetProcAddress(m_hDll, "PrtDefineBufferedImageA");
	DefineBufferedImageW = (PrtDefineBufferedImageW)GetProcAddress(m_hDll, "PrtDefineBufferedImageW");
	PrintBufferedImage = (PrtPrintBufferedImage)GetProcAddress(m_hDll, "PrtPrintBufferedImage");
	DefineDownloadedImageCompatibleA = (PrtDefineDownloadedImageCompatibleA)GetProcAddress(m_hDll, "PrtDefineDownloadedImageCompatibleA");
	DefineDownloadedImageCompatibleW = (PrtDefineDownloadedImageCompatibleW)GetProcAddress(m_hDll, "PrtDefineDownloadedImageCompatibleW");
	PrintDownloadedImageCompatible = (PrtPrintDownloadedImageCompatible)GetProcAddress(m_hDll, "PrtPrintDownloadedImageCompatible");

	OpenDrawer = (PrtOpenDrawer)GetProcAddress(m_hDll, "PrtOpenDrawer");
	SelectStandardMode = (PrtSelectStandardMode)GetProcAddress(m_hDll, "PrtSelectStandardMode");
	SetTextLineSpace = (PrtSetTextLineSpace)GetProcAddress(m_hDll, "PrtSetTextLineSpace");
	SetTextPosition = (PrtSetTextPosition)GetProcAddress(m_hDll, "PrtSetTextPosition");
	SelectPageMode = (PrtSelectPageMode)GetProcAddress(m_hDll, "PrtSelectPageMode");
	SetPrintAreaInPageMode = (PrtSetPrintAreaInPageMode)GetProcAddress(m_hDll, "PrtSetPrintAreaInPageMode");
	SelectPrintDirectionInPageMode = (PrtSelectPrintDirectionInPageMode)GetProcAddress(m_hDll, "PrtSelectPrintDirectionInPageMode");
	SetAbsolutePrintPosition = (PrtSetAbsolutePrintPosition)GetProcAddress(m_hDll, "PrtSetAbsolutePrintPosition");
	SetAbsoluteVerticalPrintPositionInPageMode = (PrtSetAbsoluteVerticalPrintPositionInPageMode)GetProcAddress(m_hDll, "PrtSetAbsoluteVerticalPrintPositionInPageMode");
	PrintAndReturnStandardMode = (PrtPrintAndReturnStandardMode)GetProcAddress(m_hDll, "PrtSetPrintAndReturnStandardMode");
	PrintDataInPageMode = (PrtPrintDataInPageMode)GetProcAddress(m_hDll, "PrtPrintDataInPageMode");
	CheckPrinterState = (PrtCheckPrinterState)GetProcAddress(m_hDll, "PrtCheckPrinterState");
	DirectIO = (PrtDirectIO)GetProcAddress(m_hDll, "PrtDirectIO");
	SetCharacterSet = (PrtSetCharacterSet)GetProcAddress(m_hDll, "PrtSetCharacterSet");
	GetPrinterVersion = (PrtGetPrinterVersion)GetProcAddress(m_hDll, "PrtGetPrinterVersion");
	PositionNextLabel = (PrtPositionNextLabel)GetProcAddress(m_hDll, "PrtPositionNextLabel");

	return TRUE;
}
