#include <iostream>
#include<windows.h>
#include<string>
using namespace std;
#define TEST_DLL_PATH "D:\\Office-5.0-project\\c\\windows-printer\\Debug\\TPrinter.dll"
#define TEST_FUNCTION_NAME "GetDefaultPrinterName"
typedef void( *TestFunction)(char*);
int main()
{
cout << "Start" << endl;
HINSTANCE hDLL = LoadLibrary(TEST_DLL_PATH);
if (hDLL == NULL)
{
cout << TEST_DLL_PATH << " ERROR: " << GetLastError() << endl;
return -1;
}
cout << TEST_DLL_PATH << " " << hDLL << endl;
TestFunction function=(TestFunction)GetProcAddress(hDLL,"GetDefaultPrinterName");
if (function == NULL)
{
cout << TEST_DLL_PATH << " ERROR:" << GetLastError() << endl;
return -1;
}
cout << TEST_FUNCTION_NAME << " " << function << endl;
char name[256] = {0};
function(name);
cout<<"RESULT="<< name << endl;
FreeLibrary(hDLL);//卸载dllTest.dll文件;
cout << "End" << endl;
return 0;
}