Calling a simple VC DLL from VB6

Calling a simple VC DLL from VB6

伪装你 发布于 2021-11-25 字数 623 浏览 725 回复 2 原文

I have a simple DLL written with VC6 with one function:

__declspec(dllexport) int myfunc(long a, unsigned char *b, unsigned char *c, unsigned char *d, unsigned char *e)

And im calling it from vb6 using:

Declare Function myfunc Lib "mylib.dll" (ByVal a As Long, ByVal b As String, ByVal c As String, ByVal d As String, ByVal e As String) As Long


dim a as long
dim b as string
dim c as string
dim d as string
dim e as string
dim r as long


Im getting "bad dll calling convention" error but I cant figure out why. Any ideas?

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。



需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。


又爬满兰若 2022-06-07 2 楼

Check out the Universal DLL function caller, by Paul Caton:

It will allow you to call pretty much any type of function from VB6.

软的没边 2022-06-07 1 楼

Generally speaking, 'bad DLL...' means what it says. VB6 requires the _stdcall convention (like the Win API) for any external functions it calls.

Try adding __stdcall to the C function prototype and see what happens.