Public Function ReturnForm(pFormName As String) As FORM_INFO_1
    Dim PrinterHandle As Long   ' 打印机句柄
    Dim pFI1 As FORM_INFO_1
    Dim Temp() As Byte
    Dim BytesNeeded As Long
    Dim RetVal As Long
    
    If OpenPrinter(Printer.DeviceName, PrinterHandle, 0&) = 0 Then Exit Function        ' 返回一个打印机句柄
    
    ReDim Temp(0)
    RetVal = GetForm(PrinterHandle, pFormName, 1, Temp(0), 0&, BytesNeeded)
    ReDim Temp(BytesNeeded)
    
    If GetForm(PrinterHandle, pFormName, 1, Temp(0), BytesNeeded, BytesNeeded) = 0 Then
        Debug.Print "错误:" & Err.LastDllError
    Else
        Debug.Print "成功返回" & pFormName
    End If
    Call CopyMemory(pFI1, Temp(0), BytesNeeded)
    ReturnForm = pFI1
    Call ClosePrinter(PrinterHandle)
End Function该函数能正常返回,但对于某些特定的pFormName,却会出现“DLL调用约定错误”,比如:
ReturnForm "A3 Extra Transvers"时就会出现此错误
ReturnForm "A3 Extra Transver" 就不会出现此错误("A3 Extra Transver"是我自定义的Form)而且错误是在函数正常结束后出现的,此时函数也已经正常返回了pFI1的值。代码方面我想是不会有问题的,实在不知道这个错误从何而来。