本文介绍了如何获取spl文件的页数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码来填充假脱机程序spl文件(获取emf文件结构)
I'm using the following code to pase spooler spl files (get the emf file structure)
#include "stdafx.h"
#include <windows.h>
#include <winspool.h>
#include <stdio.h>
#include <locale.h>
#include <tchar.h>
#include <iostream>
using namespace std;
BOOL AnalyseFile(const char* pszFileName);
void UPFM(const wchar_t pszInfo[])
{
wprintf(L"%s\n",pszInfo);
}
static char* ID_Func[] =
{
"EMF_HEADER", "EMF_POLYBEZIER", "EMF_POLYGON", "EMF_POLYLINE",
"EMF_POLYBEZIERTO", "EMF_POLYLINETO", "EMF_POLYPOLYLINE",
"EMF_POLYPOLYGON", "EMF_SETWINDOWEXTEX", "EMF_SETWINDOWORGEX",
"EMF_SETVIEWPORTEXTEX", "EMF_SETVIEWPORTORGEX","EMF_SETBRUSHORGEX",
"EMF_EOF","EMF_SETPIXELV","EMF_SETMAPPERFLAGS","EMF_SETMAPMODE",
"EMF_SETBKMODE", "EMF_SETPOLYFILLMODE","EMF_SETROP2",
"EMF_SETSTRETCHBLTMODE", "EMF_SETTEXTALIGN", "EMF_SETCOLORADJUSTMENT",
"EMF_SETTEXTCOLOR","EMF_SETBKCOLOR", "EMF_OFFSETCLIPRGN","EMF_MOVETOEX",
"EMF_SETMETARGN","EMF_EXCLUDECLIPRECT","EMF_INTERSECTCLIPRECT",
"EMF_SCALEVIEWPORTEXTEX", "EMF_SCALEWINDOWEXTEX","EMF_SAVEDC",
"EMF_RESTOREDC", "EMF_SETWORLDTRANSFORM","EMF_MODIFYWORLDTRANSFORM",
"EMF_SELECTOBJECT","EMF_CREATEPEN","EMF_CREATEBRUSHINDIRECT","EMF_DELETEOBJECT",
"EMF_ANGLEARC","EMF_ELLIPSE","EMF_RECTANGLE","EMF_ROUNDRECT",
"EMF_ARC", "EMF_CHORD", "EMF_PIE", "EMF_SELECTPALETTE", "EMF_CREATEPALETTE",
"EMF_SETPALETTEENTRIES","EMF_RESIZEPALETTE","EMF_REALIZEPALETTE",
"EMF_EXTFLOODFILL","EMF_LINETO", "EMF_ARCTO","EMF_POLYDRAW",
"EMF_SETARCDIRECTION", "EMF_SETMITERLIMIT","EMF_BEGINPATH","EMF_ENDPATH",
"EMF_CLOSEFIGURE","EMF_FILLPATH","EMF_STROKEANDFILLPATH",
"EMF_STROKEPATH","EMF_FLATTENPATH","EMF_WIDENPATH",
"EMF_SELECTCLIPPATH", "EMF_ABORTPATH", "69--Unknown",
"EMF_GDICOMMENT", "EMF_FILLRGN", "EMF_FRAMERGN", "EMF_INVERTRGN",
"EMF_PAINTRGN ", "EMF_EXTSELECTCLIPRGN", "EMF_BITBLT ", "EMF_STRETCHBLT",
"EMF_MASKBLT", "EMF_PLGBLT", "EMF_SETDIBITSTODEVICE", "EMF_STRETCHDIBITS",
"EMF_EXTCREATEFONTINDIRECTW", "EMF_EXTTEXTOUTA ", "EMF_EXTTEXTOUTW",
"EMF_POLYBEZIER16", "EMF_POLYGON16 ", "EMF_POLYLINE16 ", "EMF_POLYBEZIERTO16",
"EMF_POLYLINETO16 ", "EMF_POLYPOLYLINE16", "EMF_POLYPOLYGON16",
"EMF_POLYDRAW16 ", "EMF_CREATEMONOBRUSH ", "EMF_CREATEDIBPATTERNBRUSHPT",
"EMF_EXTCREATEPEN", "EMF_POLYTEXTOUTA ", "EMF_POLYTEXTOUTW", "EMF_SETICMMODE",
"EMF_CREATECOLORSPACE", "EMF_SETCOLORSPACE ", "EMF_DELETECOLORSPACE ",
"EMF_GLSRECORD ", "EMF_GLSBOUNDEDRECORD", "EMF_PIXELFORMAT",
"EMF_RESERVED_105 ", "EMF_RESERVED_106 ", "EMF_RESERVED_107",
"EMF_RESERVED_108 ", "EMF_RESERVED_109", "EMF_RESERVED_110 ",
"EMF_COLORCORRECTPALETTE", "EMF_SETICMPROFILEA ", "EMF_SETICMPROFILEW ",
"EMF_ALPHABLEND", "EMF_SETLAYOUT ", "EMF_TRANSPARENTBLT", "EMF_RESERVED_117 ",
"EMF_GRADIENTFILL", "EMF_RESERVED_119 ", "EMF_RESERVED_120",
"EMF_COLORMATCHTOTARGETW", "EMF_CREATECOLORSPACEW"
};
int main()
{
setlocale(LC_ALL,"");
const char* pszFileName = "C:\\Program Files (x86)\\iNOV\\Print\\Temp\\00031.SPL";
if(!AnalyseFile(pszFileName))
printf("Analyse File Failed!");
else
printf("Analyse File Successed Completed!");
return 0;
}
BOOL AnalyseFile(const char* pszFileName)
{
BOOL bRet = FALSE;
DWORD dwStartPos = 0;
FILE * f ;
f = fopen("log.txt", "w");
FILE* pFile = fopen(pszFileName,"rb");
if(!pFile)
{
fprintf(f,"Open File Failed!");
return bRet;
}
/* =======================Headers================================ */
DWORD dwTmp = 0;
fseek(pFile,0,0);
fread(&dwTmp,sizeof(DWORD),1,pFile);
fread(&dwTmp,sizeof(DWORD),1,pFile);
dwStartPos = dwTmp;
fread(&dwTmp,sizeof(DWORD),1,pFile);
long pos = ftell(pFile);
fseek(pFile,dwTmp,SEEK_SET);
wchar_t pszInfo[256] = {0};
pszInfo[0] = L'(';
WORD wTmp;
int i;
for( i = 1;;i++)
{
fread(&wTmp,sizeof(wTmp),1,pFile);
if(!wTmp)
break;
memcpy((char*)&pszInfo[i],&wTmp,sizeof(wTmp));
}
pszInfo[i] = L')';
UPFM(pszInfo);
fseek(pFile,pos,SEEK_SET);
fread(&dwTmp,sizeof(DWORD),1,pFile);
fseek(pFile,dwTmp,SEEK_SET);
memset(pszInfo,0,sizeof(wchar_t)*256);
pszInfo[0] = L'(';
for(i = 1;;i++)
{
fread(&wTmp,sizeof(wTmp),1,pFile);
if(!wTmp)
break;
memcpy((char*)&pszInfo[i],&wTmp,sizeof(wTmp));
}
pszInfo[i] = L')';
UPFM(pszInfo);
/* ======================== Unknown datas ================================= */
fseek(pFile,dwStartPos,SEEK_SET);
fread(&dwTmp,sizeof(DWORD),1,pFile);
fread(&dwTmp,sizeof(DWORD),1,pFile);
/* ======================== Record datas ================================= */
DWORD dwTmp2 = 0;
for(int i=0;;i++)
{
pos = ftell(pFile);
fread(&dwTmp,sizeof(DWORD),1,pFile);
fread(&dwTmp2,sizeof(DWORD),1,pFile);
FILE *f;
f = fopen("log.txt", "a");
fprintf(f,"index: (%04d) type: 0x%04X size: %04d 0x%08X (%s)\n",i,dwTmp,dwTmp2,pos,ID_Func[dwTmp-1]);
fclose (f);
if(dwTmp == 0x0E)
{
break;
}
fseek(pFile,pos+dwTmp2,SEEK_SET);
}
fclose (f);
if(pFile) fclose(pFile);
bRet = TRUE;
return bRet;
}
有没有办法用这种方法计算spl文件的页数?
Is there a way to calculate page count of the spl file with this method?
推荐答案
这篇关于如何获取spl文件的页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!