dai2248157327 2021-04-08 20:33 采纳率: 25%
浏览 38

vba中API函数调用问题

Private Declare Function OpenPrinter Lib 'winspool. drv' Alias 'OpenPrinterA' (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long 
Private Declare Function EnumJobs Lib 'winspool. drv' Alias 'EnumJobsA' (ByVal hPnnter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, ByVal Level As Long, pJob As Any, ByVal cdBuf As Long,  pcbNeeded As Long, pcReturned As Long) As Long                                                                              
Private Declare PtrSafe Function addjob Lib 'winspool. drv' Alias' AddJobA' (ByVal hPrinter As Long, ByVal Level As Long, pData As dy, ByVal cdBuf As Long, pcbNeeded As Long) As Long 
Private Declare PtrSafe Function tjjob Lib'winspool. drv' Alias 'ScheduleJob' (ByVal hPrinter As Long, ByVal Jobld As Long) As Long 
Private Type dy 
path As String 
id As Long 
End type
Sub test () 
dim r As dy 
OpenPrinter 'Fujitsu DPK890T', hPrinter, ByVal 0&
tr ='E: \123. txt 
r.path = tr
r.id= 1

addjob hPrinter,1,r,10,5
shuchu = addjob (hPrinter,1,r,10,5)           
Debug. Print shuchu                                                                   
tjjob hPrinter, r.id
end sub

为什么上述API函数调用不成功,返回的值为0,无法直接打印相关的123.txt文件?

如何实现调用上述函数成功,实现打印功能?

  • 写回答

2条回答 默认 最新

  • 有问必答小助手 2021-04-09 09:52
    关注

    您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    评论

报告相同问题?

悬赏问题

  • ¥15 Apache显示系统错误3该如何解决?
  • ¥30 uniapp小程序苹果手机加载gif图片不显示动效?
  • ¥20 js怎么实现跨域问题
  • ¥15 C++dll二次开发,C#调用
  • ¥15 请教,如何使用C#加载本地摄像头进行逐帧推流
  • ¥15 Python easyocr无法顺利执行,如何解决?
  • ¥15 求一个十多年前的国产符号计算软件(MMP)+用户手册
  • ¥15 为什么会突然npm err!啊
  • ¥15 java服务连接es读取列表数据,服务连接本地es获取数据时的速度很快,但是换成远端的es就会非常慢,这是为什么呢
  • ¥15 vxworks交叉编译gcc报错error: missing binary operator before token "("