vb中调用C动态链接库的问题

mrh123 2003-03-03 10:54:00
库内容

// File: MYPUTS.C.
// The myPuts function writes a null-terminated string to
// the standard output device.

#include <windows.h>

__declspec(dllexport) int __cdecl myPuts(LPTSTR lpszMsg)
{
// if you want to a function can be used in other pro,you must
// add flag __declspec(dllexport)
DWORD cchWritten;
HANDLE hStdout;

// Get a handle to the standard output device.

hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

// Write a null-terminated string to the standard output device.
while (*lpszMsg)
WriteFile(hStdout, lpszMsg++, 1, &cchWritten, NULL);

return 0;
}


VB工程调用

Private Declare Function myPuts Lib "e:\vb98\dll\myPuts.dll" (ByVal lpszMsg As String) As Integer
Private Sub Command1_Click()
Dim showStr As String

showStr = String(32, 0)
showStr = "123"

myPuts showStr

End Sub

问题:
BAD DLL calling convention

求助,谢谢!
...全文
36 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mrh123 2003-03-04
  • 打赏
  • 举报
回复
it cann't work for error "cann't find DLL entry point myPuts in e:\vb98\dll\myPuts.dll"
bigbigfans 2003-03-03
  • 打赏
  • 举报
回复
Up
gang75 2003-03-03
  • 打赏
  • 举报
回复
gz
用户 昵称 2003-03-03
  • 打赏
  • 举报
回复
try declare dll export like this
__declspec( dllexport ) int __stdcall

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧