• VB 如何调用 c++ DLL?


    
    ```Class MainWindow
    
        'ByVal 值传递 ByRef 引用传递
        'Function 有返回值 Sub 无返回值
        'C语言数据类型在VisualBasic中声明为调用时使用的表达式
        'ATOM ByVal variable As Integer 结果为Integer 类型的表达式
        'BOOL ByVal variable As Long 结果为 Long 类型的表达式
        'Byte ByVal variable As Byte 结果为 Byte 类型的表达式
        'Char ByVal variable As Byte 结果为 Byte 类型的表达式
        'COLORREF ByVal variable As Long 结果为 Long 类型的表达式
        'DWORD ByVal variable As Long 结果为 Long 类型的表达式
        'HWND, HDC, HMENU ByVal variable As Long 结果为 Long 类型的表达式等Windows 句柄
        'INT, UINT ByVal variable As Long 结果为 Long 类型的表达式
        'Long ByVal variable As Long 结果为 Long 类型的表达式
        'LPARAM ByVal variable As Long 结果为 Long 类型的表达式
        'LPDWORD variable As Long 结果为 Long 类型的表达式
        'LPINT, LPUINT variable As Long 结果为 Long 类型的表达式
        'LPRECT variable As Type 自定义类型的任意变量
        'LPSTR, LPCSTR ByVal variable As String 结果为 String 类型的表达式
        'LPVOID variable As Any 任何变量(在传递字符串的时候使用ByVal)
        'LPWORD variable As Integer 结果为Integer 类型的表达式
        'LRESULT ByVal variable As Long 结果为 Long 类型的表达式
        'NULL As Any 或 ByVal Nothing 或
        'ByVal variable As Long ByVal 0& 或 VBNullString
        'Short ByVal variable As Integer 结果为Integer 类型的表达式
        'VOID Sub procedure() 不可用
        'WORD ByVal variable As Integer 结果为Integer 类型的表达式
        'WPARAM ByVal variable As Long 结果为 Long 类型的表达式
        Private Declare Auto Function MSBox Lib "user32.dll" Alias "MessageBox" (ByVal hWnd As Integer, ByVal txt As String, ByVal caption As String, ByVal Typ As Integer) As Integer
        Private Declare Function VB_CreateOCRInstance Lib "CoCoOCR.dll" () As Long
        Private Declare Sub VB_ReleaseOCRInstance Lib "CoCoOCR.dll" ()
    
        Private Declare Function VB_Recognize Lib "CoCoOCR.dll" (ByVal filePath As String, ByVal result As String, ByVal len As Integer) As Integer
        Private Declare Function VB_RecognizeEx Lib "CoCoOCR.dll" (ByVal filePath As String, ByVal result As String, ByVal len As Integer, ByVal type As Integer) As Integer
        Private Declare Function VBRecognizeExEx Lib "CoCoOCR.dll" (ByVal filePath As String, ByVal result As String, ByVal len As Integer, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Integer
    
        Const MB_ICONQUESTION As Integer = &H20
        Const MB_YESNO As Integer = &H4
        Const IDYES As Integer = 6
        Const IDNO As Integer = 7
        Private Sub button_Click(sender As Object, e As RoutedEventArgs) Handles button.Click
            ' Stores the return value.
            Dim RetVal As Integer
            RetVal = MSBox(0, "Declare DLL Test", "Windows API MessageBox", MB_ICONQUESTION Or MB_YESNO)
    
            ' Check the return value.
            If RetVal = IDYES Then
                MsgBox("You chose Yes")
            Else
                MsgBox("You chose No")
            End If
        End Sub
    
    
        Private Sub button1_Click(sender As Object, e As RoutedEventArgs) Handles button1.Click
            Dim ret As Long
            Dim retRc As Integer
            ret = VB_CreateOCRInstance()
    
            If ret <> 0 Then
            Else
                Dim result As String = Space$(1024)
                Dim len As Integer = 1024
                Dim path As String = "D:VisualStudioDocument_VS2015CoCoOCRReleaseIMG_200WBS.jpg"
                retRc = VB_Recognize(path, result, len)
                textBox.Text = result
            End If
            VB_ReleaseOCRInstance();
    
        End Sub
    
        Private Sub button2_Click(sender As Object, e As RoutedEventArgs) Handles button2.Click
    
        End Sub
    End Class
  • 相关阅读:
    arcgis server 9.2代码阅读笔记一:在图层中增加一个点
    mapx+vb实战摘要
    F# 程式設計入門 (1)
    arcgis server 9.2代码阅读笔记二:在页面上动态加载图层
    F#维基百科,自由的百科全书(重定向自F#)
    用VC++进行MapX二次开发
    sdsalea process in sd
    abap关于sap地址,传真,邮箱的地址读取
    SDEnterprise Structure Configuration
    ABAP通过LDB_PROCESS函数使用逻辑数据库
  • 原文地址:https://www.cnblogs.com/cheungxiongwei/p/8308474.html
Copyright © 2020-2023  润新知