#include "StdAfx.h"
#include "lyfzLoadLibrary.h"

namespace lyfzLibrary
{
	HMODULE g_hCloudSelectionLib = NULL;

	API_uploadorder g_uploadorder = NULL;
	API_uploadgoodinfo g_uploadgoodinfo = NULL;
	API_uploadimg g_uploadimg = NULL;
	API_getcloundresult g_getcloundresult = NULL;

	BOOL LoadCloudSelectionLib()
	{
		if ( g_hCloudSelectionLib == NULL )
			g_hCloudSelectionLib = LoadLibrary(_T("lyfzCloudSelection.dll"));

		if ( !g_hCloudSelectionLib )
		{
			AfxMessageBox(_T("�������ӿ�ʧ��"));
			return FALSE;
		}

		g_uploadorder = (API_uploadorder)GetProcAddress(g_hCloudSelectionLib, "uploadorder");
		if ( g_uploadorder == NULL )
		{
			AfxMessageBox(_T("��ȡ�����ƽӿ�ʧ��"));
			return FALSE;
		}

		g_uploadgoodinfo = (API_uploadgoodinfo)GetProcAddress(g_hCloudSelectionLib, "uploadgoodinfo");
		if ( g_uploadgoodinfo == NULL )
		{
			AfxMessageBox(_T("��ȡ�����ƽӿ�ʧ��"));
			return FALSE;
		}

		g_uploadimg = (API_uploadimg)GetProcAddress(g_hCloudSelectionLib, "uploadImg");
		if ( g_uploadimg == NULL )
		{
			AfxMessageBox(_T("��ȡ�����ƽӿ�ʧ��"));
			return FALSE;
		}
		
		g_getcloundresult = (API_getcloundresult)GetProcAddress(g_hCloudSelectionLib, "getresult");
		if ( g_getcloundresult == NULL )
		{
			return FALSE;
		}

		return TRUE;
	}

	void FreeCloudSelectionLib()
	{
		if ( g_hCloudSelectionLib )
			FreeLibrary(g_hCloudSelectionLib);
	}

};