VB.NET调用打印机DLL函数PInvokeStackImbalance [英] VB.NET Call Printer dll Function PInvokeStackImbalance
问题描述
大家好,
我在VB.NET(VS 2013)中控制ID卡打印机(HiTi CS-200e)时遇到问题。
它带有一个dllPavoApi.dll(似乎是一个非托管的dll)。
DLL链接到项目中并位于项目目录中。 />
我尝试将ID卡移入打印机。
参考pinters SDK docs我必须使用
DWORD __ stdcall PAVO_MoveCard( char * szPrinter,DWORD dwPosition);
我尝试将其翻译成VB.NET,并使用
Imports System.Runtime.InteropServices
Friend Class HiTiDLL
< DllImport( PavoApi.dll,CallingConvention:= CallingConvention .Cdecl)GT; _
公开 共享 功能 PAVO_MoveCard( ByVal szPrinter As String ,< span class =code-keyword> ByVal dwPosition 作为 长)作为 整数
结束 < span class =code-keyword>功能
公共 功能 HitiMoveCard( ByVal PrinterName As String , ByVal 位置作为 长)作为 整数
返回 PAVO_MoveCard(PrinterName,Position)
结束 功能
结束 类
公共 类 cls_HiTiPrinterControl
公共 Sub 测试()
Dim HiTi 作为 新 HiTiDLL
HiTi.HitiMoveCard ( HiTi CS-200e, 3 )
结束 Sub
结束 类
调试器返回PInvokeStackImbalance。
我是非管理dll的新手,所以出了什么问题?
感谢您的帮助。
Phil
等价物在VB.NET中DWORD
是Integer
;在VB6中它本来是Long
,它仍然植根于16位世界。
另外,我不认为CallingConvention.Cdecl
匹配你的__ stdcall
声明。
尝试:
朋友 类 HiTiDLL
< DllImport( < span class =code-string> PavoApi.dll)> _
公开 共享 功能 PAVO_MoveCard( ByVal szPrinter As String ,< span class =code-keyword> ByVal dwPosition 作为 整数)作为 整数
结束 < span class =code-keyword>功能
公共 功能 HitiMoveCard( ByVal PrinterName As String , ByVal 位置作为 整数)作为 整数
返回 PAVO_MoveCard(PrinterName,Position)
结束 功能
结束 类跨度>
Hi everyone,
I'm have problems to control a ID-Card Printer (HiTi CS-200e) in VB.NET (VS 2013).
It comes with a dll "PavoApi.dll" (seems to be an unmanaged dll).
The DLL is linked into the project and is in the project directory.
I try to move the ID-Card into the printer.
Referring to the pinters SDK docs I have to use
DWORD __stdcall PAVO_MoveCard(char* szPrinter, DWORD dwPosition);
I tried to translate it into VB.NET with
Imports System.Runtime.InteropServices
Friend Class HiTiDLL
<DllImport("PavoApi.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Shared Function PAVO_MoveCard(ByVal szPrinter As String, ByVal dwPosition As Long) As Integer
End Function
Public Function HitiMoveCard(ByVal PrinterName As String, ByVal Position As Long) As Integer
Return PAVO_MoveCard(PrinterName, Position)
End Function
End Class
Public Class cls_HiTiPrinterControl
Public Sub Test()
Dim HiTi As New HiTiDLL
HiTi.HitiMoveCard("HiTi CS-200e", 3)
End Sub
End Class
The debugger returns "PInvokeStackImbalance".
I'm new to unmanaged dlls, so what's going wrong?
Thank's for any help.
Phil
The equivalent ofDWORD
isInteger
in VB.NET; it would have beenLong
in VB6, which was still rooted in the 16-bit world.
Also, I don't thinkCallingConvention.Cdecl
matches your__stdcall
declaration.
Try:
Friend Class HiTiDLL <DllImport("PavoApi.dll")> _ Public Shared Function PAVO_MoveCard(ByVal szPrinter As String, ByVal dwPosition As Integer) As Integer End Function Public Function HitiMoveCard(ByVal PrinterName As String, ByVal Position As Integer) As Integer Return PAVO_MoveCard(PrinterName, Position) End Function End Class
这篇关于VB.NET调用打印机DLL函数PInvokeStackImbalance的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!