以下是把打印机纸张代码转换为尺寸信息,运行时出错了,我离“实现win2000自定义报表在其它机器不用做任何设置”的程序就差这一步了,请各位帮帮我吧!我成功后,一定会把代码奉献给大家的。
*----------------------------------------------------------
#DEFINE DC_MAXEXTENT 5
#DEFINE DC_MINEXTENT 4
#DEFINE DC_PAPERNAMES 16
#DEFINE DC_PAPERS 2
#DEFINE DC_PAPERSIZE 3
#DEFINE SIZE_LONG 4
#DEFINE SIZE_INT 2
DECLARE LONG DeviceCapabilities IN WinSpool.Drv;
STRING lpDeviceName,;
STRING lpPort,;
LONG iIndex,;
STRING @lpOutput,;
STRING @lpDevMode
* lpOutput: 缓冲区的地址,能力数据会装载到这个缓冲区中。
* lpDevMode: 一个DEVMODE结构的地址,或者为零。
***********************************************************
* 名称:GetPaperInfo
* 功能:得到打印机低张信息
***********************************************************
LOCAL lcPrinter,lcPort,lnCount
LOCAL lnRet,lcBuffer,lnPapers
LOCAL lnMaxLength,lnMaxWidth
LOCAL lnMinLength,lnMinWidth
lcPrinter = SET("Printer",3)
lcPort = "LPT1"
*支持最大打印纸:失败!
lnRet = DeviceCapabilities(lcPrinter,lcPort,DC_MAXEXTENT,0,0)
lnMaxLength = INT(lnRet / 65536)
lnMaxWidth = lnRet % 65536
*支持最小打印纸:失败!
lnRet = DeviceCapabilities(lcPrinter,lcPort,DC_MINEXTENT,0,0)
lnMinLength = INT(lnRet / 65536)
lnMinWidth = lnRet % 65536
*支持纸张种类数:
lnPapers = DeviceCapabilities(lcPrinter,lcPort,DC_PAPERS,0,0)
*纸张编号:
LOCAL laPaperNo(lnPapers)
lcBuffer = SPACE(SIZE_INT * lnPapers)
= DeviceCapabilities(lcPrinter,lcPort,DC_PAPERS,@lcBuffer,0)
FOR lnCount = 1 TO lnPapers
laPaperNo(lnCount) = C2BIN(SUBSTR(lcBuffer,(lnCount - 1) * SIZE_INT + 1,SIZE_INT)) && 出错了,提示:“函数名缺少 )”
ENDFOR
*纸张名称:
LOCAL laPageName(lnPapers)
lcBuffer = SPACE(lnPapers * 64)
= DeviceCapabilities(lcPrinter,lcPort,DC_PAPERNAMES,@lcBuffer,0)
= ALINES(laPageName,lcBuffer,5,CHR(0))
*纸张尺寸:
LOCAL laPageSize(lnPapers,2)
lcBuffer = SPACE(lnPapers * SIZE_LONG * 2)
= DeviceCapabilities(lcPrinter,lcPort,DC_PAPERSIZE,@lcBuffer,0)
FOR lnCount = 1 TO lnPapers * 2
laPageSize(lnCount) = C2BIN(SUBSTR(lcBuffer,(lnCount - 1) * SIZE_LONG + 1,SIZE_LONG))
ENDFOR
SUSPEND
FUNCTION C2BIN
LPARAMETERS tcString
LOCAL lnRet,lnCount
lnRet = 0
FOR lnCount = LEN(tcString) TO 1 STEP -1
lnRet = lnRet * 256 + ASC(SUBSTR(tcString,lnCount,1))
ENDFOR
RETURN lnRet
*------------------------------ \\ 以上出错如下!!
laPaperNo(lnCount) = C2BIN(SUBSTR(lcBuffer,(lnCount - 1) * SIZE_INT + 1,SIZE_INT)) && 出错了,提示:“函数名缺少 )”
*------------------------------ \\
我离“实现win2000自定义报表在其它机器不用做任何设置”的程序就差这一步了,请各位帮帮我吧!我成功后,一定会把代码奉献给大家的。