阅读:1546回复:3
■■如何把驱动中截取的信息正确的写入到文件中??????????
DWORD pcbNeeded=0;
DWORD pcReturned=0; JOB_INFO_2 * pJobInfo=NULL; SYSTEMTIME st; pJobInfo = (JOB_INFO_2 *) LocalAlloc(LPTR, pcbNeeded); GetJob(pdevobj->hPrinter,dwJobId,1,(LPBYTE)pJobInfo,pcbNeeded,(LPDWORD)&pcReturned); HANDLE hDIBFile = NULL; hDIBFile = CreateFile(TEXT("c:\\ffdgfaa4aa.xml"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); BOOL bRet = FALSE; DWORD NumByteWritten = 0; char *log="<Log><printlog><job_id>"; //int iSize; //char* pszMultiByte; // //iSize = WideCharToMultiByte(CP_ACP, 0, pJobInfo->pDocument, -1, NULL, 0, NULL, NULL); //pszMultiByte = (char*)malloc((iSize+1)/**sizeof(char)*/); //WideCharToMultiByte(CP_ACP, 0, pJobInfo->pDocument, -1, pszMultiByte, iSize, NULL, NULL); bRet = WriteFile(hDIBFile,log,strlen(log) , &NumByteWritten, NULL); bRet = WriteFile(hDIBFile,pJobInfo->pDocument,sizeof(pJobInfo->pDocument), &NumByteWritten, NULL); CloseHandle(hDIBFile); 写到文件中的东西是乱码!!!!!!!!!!!!!!!!!!!! why ??????? |
|
沙发#
发布于:2007-02-05 10:40
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于:2007-02-05 11:44
能详细点吗?
|
|
地板#
发布于:2007-02-05 11:59
OEMStartDoc(
SURFOBJ *pso, PWSTR pwszDocName, DWORD dwJobId) { TERSE(UNITEXT("OEMStartDoc() entry.\r\n")); PDEVOBJ pdevobj = (PDEVOBJ)pso->dhpdev; POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM; //记录打印机详细信息 DWORD pcbNeeded=0; DWORD pcReturned=0; JOB_INFO_2 * pJobInfo=NULL; SYSTEMTIME st; pJobInfo = (JOB_INFO_2 *) LocalAlloc(LPTR, pcbNeeded); GetJob((HANDLE)pdevobj->hPrinter,dwJobId,2,(LPBYTE)pJobInfo,pcbNeeded,(LPDWORD)&pcReturned); //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑这样写是否能得到正确的信息 /////如果能 那如何记录到文件如xml文件 txt文件 等 // turn around to call Unidrv return (((PFN_DrvStartDoc)(pOemPDEV->pfnUnidrv[UD_DrvStartDoc])) ( pso, pwszDocName, dwJobId )); } |
|