Take the following steps to create and run a program that uses the LEADTOOLS Network Virtual Printer Driver.
Start Visual Studio 2008.
From the Main Menu, choose File->New->Project...
In the New Project dialog box, choose Visual C++ in the Projects Types, and choose MFC Application in the Templates.
Type the project name as LEADTOOLS Printer Client Installer in the Project Name field.
In the Location field, use the Browse button to navigate to the Examples subdirectory (such as C:\LEADTOOLS22\Examples\VirtualPrinter\CDLL). Clear both the Create Directory For Solution and the Add To Source Control check boxes. Click OK.
Click Next> in the MFC Application Wizard.
Select the Dialog-based Application type. Then click Finish. Three folders will be created, entitled: "Header Files", "Resource Files", and "Source Files".
From the Main Menu, choose Project->Properties.
In the Properties dialog box, choose Configuration Properties, then select C/C++ and then select Preprocessor.
In right side set Preprocessor definitions property to use LTVXX_CONFIG then click OK.
In Solution Explorer, open stdafx.h and add the following code to the end of it:
#include "..\..\..\Include\LtprinterClientInstaller.h"
In the Source Files, right-click the folder. Choose Add->New Item. Choose Code in Categories, and C++ File(.cpp) in Templates. Type Imports in the name field and click Add.
Right-click Imports.cpp and click Open. Add the following code to it:
#include "stdafx.h"
#if defined(WIN64)
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\cdll\\x64\\LtprinterClientInstaller_x.lib")
#else
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\cdll\\win32\\LtprinterClientInstaller_u.lib")
#endif // #if defined(WIN64)
Right-click LEADTOOLS Printer Client InstallerDlg.h and click Open. Add the following code to it:
//add the following function definition to the CLEADTOOLSPrinterClientInstallerDlg functions
afx_msg void OnBnClickedOk();
Right-click LEADTOOLS Printer Client InstallerDlg.cpp and click Open. Add the following code to it:
//locate BEGIN_MESSAGE_MAP and add the following line
ON_BN_CLICKED(IDOK, &CLEADTOOLSPrinterClientInstallerDlg::OnBnClickedOk)
afx_msg void CLEADTOOLSPrinterClientInstallerDlg::OnBnClickedOk()
{
/*
"Printer Name" : the name of a shared printer on the server machine
"Printer DLL" : printer demo DLL
"Printer Server" : the name of the printer server
*/
L_PrnClntSetPrinterConnectionDll("printer's name", "Printer DLL", "Printer Server");
}
Compile and run the code to test it. The printer selected will be connected and installed on the machine.
For more information, refer to:
Working with the LEADTOOLS Virtual Printer