首页 > 解决方案 > AutoIt - DllCall - 我的 dll 调用不返回值

问题描述

我使用 - C#、vb.net 和 FreeBasic 创建了自己的 dll - 功能是添加 2 个。返回值为空白(使用 FreeBasic 时)或 0(对于 c# 和 vb.net)。

有人可以在这件事上帮助我吗?

AutoIt 代码很简单,如下所示:

#include <MsgBoxConstants.au3>
;Local $hDLL = DllOpen(@ScriptDir & "\clsAddMul.dll") ; vb.net & c#
Local $hDLL = DllOpen(@ScriptDir & "\Math1.dll") ;FreeBasic

Local $aResult = 555

$aResult = DllCall($hDLL, "Int", "_add", "Int", 7, "Int", 8)
;$aResult = DllCall($hDLL, "int", "_add", "int", 7, "int", 8)

DllClose($hDLL)

MsgBox (0, "Result", "Total = " & $aResult)

功能代码如下:

1 - FreeBasic 代码:

Extern "Windows-MS"

Function _add(no1 As Integer, no2 As Integer) As Integer Export
    Dim result As Integer
    result = no1 + no2
'   result = 10

'   Return no1+no2  
    Return result   

End Function
End Extern

同样,vb.net 和 c# 也没有 Extern 和 Export 等。这里没有包括它,因为它的例子非常简单。

标签: autoit

解决方案


推荐阅读