我在使用 crpe32.dll 打印 Crystal Reports 时遇到问题(由于某些原因,我们无法使用 CrystalDecisions.CrystalReports.Engine 中的 ReportDocument clss)。当我尝试打印没有参数的报告时,没有任何错误。使用导入的dll中的方法就足够了:
- PEOpenEngine
- PEOpenPrintJob
- PEOutputToPrinter
- PEStartPrintJob
- PEClosePrintJob
- PECloseEngine
但是我在必须传递结构的方法上遇到问题,例如 PEGetNthParameterField 或 PEAddParameterCurrentValue。结果我仍然得到“错误”,我的结构没有改变。
private static void PrintTest()
{
int o1 = PEOpenEngine();
if (o1 == 0)
{
return;
}
int o2 = PEOpenPrintJob("someReport.rpt");
short paramCounts = PEGetNParameterFields(o2); // I've got here 4 in one of my real reports
PEParameterFieldInfo paramInfo = new PEParameterFieldInfo();
paramInfo.StructSize = 316;
bool isParamCorrect = PEGetNthParameterField(o2, 0, ref paramInfo); // false :( and unchanged paramInfo
int o3 = PEOutputToPrinter(o2, 1);
int o4 = PEStartPrintJob(o2, true);
int o5 = PEClosePrintJob(o2);
int oLast = PECloseEngine();
}
[DllImport("crpe32.dll")]
static extern short PEGetNParameterFields(int PrintJob);
[DllImport("crpe32.dll")]
static extern bool PEGetNthParameterField(int PrintJob, int parameterN, ref PEParameterFieldInfo parameterInfo);
可能是我的问题的根源 - PEParameterFieldInfo 结构
public struct PEParameterFieldInfo
{
public int StructSize;
public int ValueType;
public int DefaultValueSet;
public int CurrentValueSet;
public string Name;
public string Prompt;
public string DefaultValue;
public string CurrentValue;
public string ReportName;
public int needsCurrentValue;
public int isLimited;
public double MinSize;
public double MaxSize;
public string EditMask;
public int isHidden;
}
你知道这里有什么问题吗?