阅读:1664回复:2
跪求这段程序错在哪?
是虚拟打印的程序,转换完的图片我希望放到d:\\sample中。在OEMStartPage函数中:
BOOL APIENTRY OEMStartPage( SURFOBJ *pso) { TERSE(UNITEXT(\"OEMStartPage() entry.\\r\\n\")); PDEVOBJ pdevobj = (PDEVOBJ)pso->dhpdev; POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM; PDEVMODE pPubDev = (PDEVMODE)pdevobj->pPublicDM; POEMDEV pOemDev = (POEMDEV)pdevobj->pOEMDM; // increment page number 页数增加 pOemPDEV->PageNum++; if(!pOemPDEV->bAppendPageNum) pOemPDEV->szPreviewFileName=\"D:\\sample\\1.bmp\"; //文件名要放的地方 if(lstrlen(pOemPDEV->szPreviewFileName))//文件名长度不为空 { TCHAR szBuffer[MAX_PATH] = {0}; PTSTR pFilePart = NULL; // 得到全部路径的名字 GetFullPathName(pOemPDEV->szPreviewFileName, MAX_PATH, szBuffer, &pFilePart); // create temp file HANDLE hFile = CreateFile(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile == INVALID_HANDLE_VALUE) { return FALSE; } else { // close & delete file CloseHandle(hFile); DeleteFile(szBuffer); } // update szPreviewFileName lstrcpy(pOemPDEV->szPreviewFileName, szBuffer); } else return FALSE; } // set resolution 设置精度 if(pPubDev->dmOrientation == DMORIENT_PORTRAIT) { pOemPDEV->DIBInfo.XPelsPerMeter = pPubDev->dmPrintQuality * 10000 / 254; pOemPDEV->DIBInfo.YPelsPerMeter = pPubDev->dmYResolution * 10000 / 254; } else { pOemPDEV->DIBInfo.XPelsPerMeter = pPubDev->dmYResolution * 10000 / 254; pOemPDEV->DIBInfo.YPelsPerMeter = pPubDev->dmPrintQuality * 10000 / 254; } // calculate approximate page height 计算纸的高度 if(pPubDev->dmOrientation == DMORIENT_PORTRAIT) pOemPDEV->approHeight = pPubDev->dmPaperLength * pPubDev->dmYResolution / 254 + 10; else pOemPDEV->approHeight = pPubDev->dmPaperWidth * pPubDev->dmPrintQuality / 254 + 10; // allocate memory for scanline pointer array 分配扫描行数的内存空间 if(!(pOemPDEV->DIBInfo.pScans = (PSCANLINEPTR)HeapAlloc(pOemPDEV->hHeap, HEAP_ZERO_MEMORY, pOemPDEV->approHeight * sizeof(SCANLINEPTR)))) { WARNING(UNITEXT(\" error(%d) occured while allocating memory for pScans!\\r\\n\"), GetLastError()); return FALSE; } // turn around to call Unidrv 进入驱动 return (((PFN_DrvStartPage)(pOemPDEV->pfnUnidrv[UD_DrvStartPage]))(pso)); } 编译完了出的错是: error c2220:warning treated as error - no object file generated error c4129:\'s\':unrecognized character escaple sequence error c2440:\'=\':cannot convert from \'char[141]\'to \'TCHART[260]\' 这些错都在 pOemPDEV->szPreviewFileName=\"D:\\sample\\1.bmp\"; //文件名要放的地方地方 错在哪?? |
|
沙发#
发布于:2005-06-02 16:56
在C语言中,\'\\\'是转义符,因此要这样写:\"D:\\\\sample\\\\1.bmp\".
pOemPDEV->szPreviewFileName是字符串,不是指针,所以要改成: strcpy( pOemPDEV->szPreviewFileName, :\"D:\\\\sample\\\\1.bmp\" ); |
|
|
板凳#
发布于:2005-06-07 17:28
1楼的大哥好快呀
到处都有你的身影 |
|
|