hookapi使打印机成像 [英] hookapi to make printer to image

查看:214
本文介绍了hookapi使打印机成像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在用户从其他应用程序打印时获取图像。

然后我挂了一些api。

首先我挂钩了createdcw和我的钩子功能,我创建一个内存dc(通过CreateCompatibleDC(NULL))并返回。但目标应用程序显示错误。



然后,我在我创建的同时创建打印机直流(call real createdcw)和内存直流,并保存内存直流在地图中,密钥是打印机直流。我还创建了一个hbitmap,其with和height与打印机dc相同(使用GetDeviceCaps(hdcPrinter,HORZRES)和GetDeviceCaps(hdcPrinter,VERTRES))。在我的钩子ExtTextOutW中(为了测试,目标应用程序在打印时使用此功能),我从地图获取打印机直流的内存直流。并调用真正的ExtTextOutW将文本绘制到内存直流和打印机直流。



和我挂钩的EndPage函数,我将内存直流保存为.bmp文件。



但是.bmp文件中的单词太小而且字符间距太大。我想也许问题是dpi,内存直流电压为96,打印机直流电压为600.



如何解决这个问题?

i want to get a image when user print from other applications.
then i hook some api.
first i hooked createdcw and in my hook funciton, i create a memory dc(by CreateCompatibleDC(NULL) ) and return. but the target application show a error.

then, i in my createdcw i create both printer dc(call real createdcw) and a memory dc, and save the memory dc in a map which the key is printer dc. i also create a hbitmap with the with and height same as printer dc(use GetDeviceCaps(hdcPrinter, HORZRES) and GetDeviceCaps(hdcPrinter, VERTRES) ). in my hooked ExtTextOutW(for test, the target application use this function when printing), i get the memory dc by printer dc from the map. and call the real ExtTextOutW to draw the text to memory dc and printer dc.

and at my hooked EndPage function, i save the memory dc to a .bmp file.

but the words in the .bmp file is too small and the character spacing is too large. i think maybe the problem is dpi, memory dc is 96 and the printer dc is 600.

How can i solve this problem?

推荐答案

我在编写打印机内容监视器时遇到了同样的问题。

我在StartDocW上挂了StartDocW EndDoc StartPage EndPage并挂钩了很多GDI APIS(DrawTextExA,FillRect ...)发生了。

我对emf文件采取行动来获取打印机内容。它通常工作正常,但与你的问题一样,记事本打印结果有小字符和大字符间距。

你现在解决了这个问题吗?
I encountered the same problem when I writing printer content monitor.
I hooked StartDocW EndDoc StartPage EndPage and hook many GDI APIS (DrawTextExA, FillRect ...)when StartDocW occured.
I tee gdi actions to emf file to get the printer content. It works ok usually, but as same as your problelm, notepad prints result have small character and large character spacing.
Are you fixed this problem now?


这篇关于hookapi使打印机成像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆