将vb6转换为autoit

时间:2011-04-02 15:35:32

标签: vb6 autoit

任何人都可以帮助我将其转换为自动,或者至少告诉我如何在autoit中执行此操作?

Private Const DC_PAPERNAMES = 16

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
    Alias "DeviceCapabilitiesW" ( _
    ByVal lpDeviceName As Long, _
    ByVal lpPort As Long, _
    ByVal iIndex As Long, _
    ByVal lpOutput As Long, _
    ByVal lpDevMode As Long) As Long

Private Sub Form_Load()
    Dim P As Printer

    For Each P In Printers
        lstPrinters.AddItem P.DeviceName
    Next
End Sub

Private Sub lstPrinters_Click()
    Dim P As Printer
    Dim lngPapers As Long
    Dim strPaperNames As String
    Dim lngPaper As Long
    Dim strPaperName As String
    Dim lngActualLength As Long

    Set P = Printers(lstPrinters.ListIndex)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   0, _
                                   0)
    strPaperNames = String$(lngPapers * 64, 0)
    lngPapers = DeviceCapabilities(StrPtr(P.DeviceName), _
                                   StrPtr(P.Port), _
                                   DC_PAPERNAMES, _
                                   StrPtr(strPaperNames), _
                                   0)
    lstPapers.Clear
    For lngPaper = 0 To lngPapers - 1
        strPaperName = Mid$(strPaperNames, 64 * lngPaper + 1, 64)
        lngActualLength = InStr(strPaperName, vbNullChar) - 1
        If lngActualLength > 1 Then strPaperName = Left$(strPaperName, lngActualLength)
        lstPapers.AddItem strPaperName
    Next
End Sub

1 个答案:

答案 0 :(得分:1)

这是一个线程,有人试图做同样的事情:http://www.autoitscript.com/forum/topic/25857-need-a-help-from-the-pros-on-making-api-call/

还有一个指南可以帮助您编写Windows API调用:http://www.autoitscript.com/forum/topic/7072-dllcall/它主要处理找到正确的类型转换,这是唯一的难点。