Take the following steps to create and run a program that uses the LEADTOOLS Network Virtual Printer Driver.
1. |
Start Visual Studio 2008. |
2. |
From the Main Menu, choose File->New->Project... |
3. |
In the New Project dialog box, choose Visual C++ in the Projects Types, and choose MFC Application in the Templates. |
4. |
Type the project name as LEADTOOLS Printer Client Installer in the Project Name field. |
5. |
In the Location field, use the Browse button to navigate to the Examples subdirectory (such as C:\LEAD Technologies\LEADTOOLS 19\Examples\CDLL). Clear both the Create Directory For Solution and the Add To Source Control check boxes. Click OK. |
6. |
Click Next> in the MFC Application Wizard. |
7. |
Select the Dialog-based Application type. Then click Finish. Three folders will be created, entitled: "Header Files", "Resource Files", and "Source Files". |
8. |
From the Main Menu, choose Project->Properties. |
9. |
In the Properties dialog box, choose Configuration Properties, then select C/C++ and then select Preprocessor. |
10. |
In right side set Preprocessor definitions property to use LTVXX_CONFIG then click OK. |
11. |
In Solution Explorer, open stdafx.h and add the following code to the end of it: |
#include "..\..\..\Include\LtprinterClientInstaller.h"
12. |
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. |
13. |
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)
14. |
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();
15. |
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");
}
16. |
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