dai2248157327 2021-04-14 23:40 采纳率: 25%
浏览 50

VBA中API函数调用问题

Private Declare PtrSafe Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Any) As Long
Private Declare PtrSafe Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter 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 JobId 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&
      Debug.Print "句柄为:" & hPrinter
       tr = "E:\123.txt"
       r.path = tr
       r.id = 1
       shuchu = addjob(hPrinter, 1, r, 10, 5)
       Debug.Print shuchu
       tjjob hPrinter, r.id
End Sub

您好,打扰了,老师!上述是是调用打印机的API函数过程,其中"Fujitsu DPK890T",为打印机名称,经过运行,句柄hPrinter是不为0,存在的,但为什么返回分shuchu值为0,显示调用不成功,这是哪里出现了问题,还望老师指点?该怎么调用才能在打印机后台显示出添加后的打印文件?

  • 写回答

3条回答 默认 最新

  • 关注

    参考一下这个资料看看:https://zhidao.baidu.com/question/165719171.html

    评论

报告相同问题?