kingmax5421
驱动牛犊
驱动牛犊
  • 注册日期2008-11-13
  • 最后登录2015-06-17
  • 粉丝1
  • 关注0
  • 积分63分
  • 威望502点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2077回复:2

无法抓取,打印任务文件名是中文的文件名

楼主#
更多 发布于:2010-05-21 10:24
RT,无法抓取,打印任务文件名是中文的文件名.
我在打印处理器里面的,PrintDocumentOnPrintProcessor事件里面,去取打印作业文件名,代码如下:  
在最后一行,取文件名,如果打印文件的文件名是英文的,DebugPrint输出正确;如果打印文件的文件名是中文的,DebugPrint输出不了起正确的文件名.

感觉是字符集的问题.但不知道问题之所在,大家指点一下.

/* Get job storage space */
if (!EnumJobsW(hPrinter,  
 0,  
 1, //NoJobs [in] The total number of print jobs to enumerate.
 2, // Job Info level 2
 NULL,  
 0,
 (LPDWORD)&cByteNeeded,
 (LPDWORD)&nReturned))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
DebugPrint("Fail to enum print jobs!");//goto Fail;
}

pJobStorage = (JOB_INFO_2W *)malloc(cByteNeeded);
ZeroMemory(pJobStorage, cByteNeeded);

/* get the list of jobs */
if (!EnumJobsW(hPrinter,  
 0,  
 1, //NoJobs [in] The total number of print jobs to enumerate.
 2,  
 (LPBYTE)pJobStorage,  
 cByteNeeded,
 (LPDWORD)&cByteUsed,
 (LPDWORD)&nReturned))
{
DebugPrint("Fail to enum print jobs!");//goto Fail;
}
DebugPrint("%ws",L"调试取文件名:");
DebugPrint("pDocument = %ws",pJobStorage[0].pDocument);
dreamsity
驱动小牛
驱动小牛
  • 注册日期2006-09-01
  • 最后登录2013-07-04
  • 粉丝0
  • 关注0
  • 积分40分
  • 威望821点
  • 贡献值1点
  • 好评度68点
  • 原创分1分
  • 专家分0分
沙发#
发布于:2010-06-17 22:33
DebugPrint不支持中文的
如果需要输出中文,先将UNICODE_STRING转换为OEM_STING,然后调用DbgPrint打印
一切都是时间问题!
mengfeng150
驱动牛犊
驱动牛犊
  • 注册日期2008-03-31
  • 最后登录2016-12-22
  • 粉丝0
  • 关注0
  • 积分61分
  • 威望583点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
  • 社区居民
板凳#
发布于:2010-06-18 09:27
ODS(("an exceptionPrinter %ws\nDocument %ws\nJobID %u\n",
                    pData->pDevmode->dmDeviceName, pData->pDocument, pData->JobId));

#if DBG


BOOL
DebugPrint(
    __in PCH pszFmt,
    ...
    );

//
// ODS - OutputDebugString
//
#define ODS( MsgAndArgs )       \
    do {                        \
        DebugPrint  MsgAndArgs;   \
    } while(0)

#else
//
// No debugging
//
#define ODS(x)
#endif             // DBG
游客

返回顶部