VB.NET调用打印机DLL函数PInvokeStackImbalance [英] VB.NET Call Printer dll Function PInvokeStackImbalance

查看:451
本文介绍了VB.NET调用打印机DLL函数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 of DWORD is Integer in VB.NET; it would have been Long in VB6, which was still rooted in the 16-bit world.

Also, I don't think CallingConvention.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆