易截截图软件、单文件、免安装、纯绿色、仅160KB

VB 6.0 调用dll的问题 - .NET技术 / VB.NET

我在VC 6.0中写了一个example.dll,里面一个函数

extern "C" __declspec(dllexport)
HRESULT __stdcall Connect(LPCSTR IpAddr)
{
...
}

example.dll中该函数名称为 _Connect@4 (用depends工具查看)

我在VB 6.0中调用此函数

Private Declare Function Connect Lib "example.dll" Alias "_Connect@4" (ByVal IpAddr As String) As Long

Dim result As Long

result = Connect("138.139.0.230")

If result <> 0 Then

  MsgBox ("error_connect")

Else

  MsgBox ("connect_ok")
   
End If

结果返回都是非0,连接失败。

但我用VC编写的代码以及用VB.NET编写同样功能的代码都可以连接上。

不知道这段VB 6.0的代码有什么不对的地方。

(只有45分了,全散了)
VB.NET和VC调用时,example.dll没有加__stdcall。(因为VB 6.0需要是stdcall)

即:

extern "C" __declspec(dllexport)
HRESULT Connect(LPCSTR IpAddr)
{
...
}

VB.NET代码如下:

Imports System.Runtime.InteropServices

<DllImport("./example.dll", CallingConvention:=CallingConvention.Cdecl)> _
  Public Function Connect(ByVal IpAddr As String) As Integer
  End Function

Dim result As Integer

result = Connect("138.139.0.230") '连接单板

If result &


相关问答:

vb操作excel - VB / 基础类

问题:
现在Access数据库中有两张表TableA和TableB
TableA中有记录如下:
字段1(Name) 字段2(Num)
  A 3
  A 4
  B 6
  ... ......

vb WebBrowser 小问题,请教 - VB / 基础类

vb WebBrowser 小问题,请教:
WebBrowser里的网址跳转后,怎么取得跳转后的页面的URL地址

顶下顶下

引用
BeforeNavigate2
好像没有这个吧 vb6.0

BeforeNavigate2
这个可以有,呵呵。
......

求助:C代码change toVB代码 - VB / 基础类

挺繁琐,之前发的帖子,分值太低现在重发一个。欢迎各位大侠~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......

VB树型结构问题 - VB / 控件

找了很久这东西了,  
用treeview不能满足要求
现在想做的是:界面以树形展现,能不能展开收回无所谓
  节点都可以按照规定进行添删
  每个节点后面都可能会出现 文本 ......

VB调用EXCEL绘图,如何修改X轴坐标 - VB / 基础类

小弟用VB调EXCEL作图
objExlApp.Workbooks.Add
  objExlApp.Charts.Add
  objExlApp.ActiveChart.ChartType = xlLine
  objExlApp.ActiveChart.HasLegend = True
  objExlApp. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号