如何在VB中将字符传参数传递给VC做成的动态库

black_mask 2002-07-26 08:47:43
vc中定义函数原形为CreateWaveFile(char *strFileName)

vb中
Declare function CreatWaveFile(byval strFileName as string) as long
函数的调用为
L=CreatWaveFile("d"\FileName.wav")
vb中提示的错误信息为dll约定错误。请教各位高手应该在vb中使用字符串变量,使传递不发生错误
...全文
6 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eastunfail 2002-07-30
ByVal别忘了阿。否则你传给函数的是指针的指针
回复
Eastunfail 2002-07-30
那么就将strFileName的地址传给那个函数,试试
L=CreateWaveFile(ByVal StrPtr("d:\FileName.wav"))
这样应该行的通,我以前也遇到类似的问题,解决了,要是实在是不行,就将字符串转换为Byte数组,将第一个元素传给该函数
回复
black_mask 2002-07-30
谢谢你的回复,不过你的办法行不通
回复
siphonelee 2002-07-26
应该是byref strFileName as string
别忘了给分哦:)
回复
mahongxi 2002-07-26
'////////////////////////////////////////////////
'Fromdll.bas
'本模块是本系统与动态链接库dfgl.dll的接口
'2001.4.17
'write by mahongxi
'
'dfgl.dll已经过测试 2001.4.19
'注意:
'在相应的C++源程序中要用关键字: _stdcall
'进行有关清栈原则的约定
'////////////////////////////////////////////////

Public Declare Function InitRegistry Lib "dfgl.dll" () As Boolean
Public Declare Function UserAdd Lib "dfgl.dll" (ByVal UserName As String, ByVal password As String) As Long
Public Declare Function UserDel Lib "dfgl.dll" (ByVal UserName As String) As Long
Public Declare Function GetUserPassword Lib "dfgl.dll" (ByVal UserName As String, ByRef pwd As String, ByRef length As Long) As Long
Public Declare Function GetUser Lib "dfgl.dll" (ByVal num As Long, ByRef name As String, ByRef length As Long) As Long


DFGL.h FILE

#include <windows.h>
//////////////////////////////////////////////////////////
#define LENGTH 30
#define MYAPPNAME "SimDfMis"
#define MYAPPKEY "SOFTWARE\\SimDfMis"
#define MYAPPPWDKEY "SOFTWARE\\SimDfMis\\dfgl_data"
#define FAILED_PWD "admin"
#define MYCODE {272,238,18,29,23,4,1,27,14,140,7,248,284,149,151}
//////////////////////////////////////////////////////////
extern "C" bool __stdcall InitRegistry();
extern "C" int __stdcall UserAdd(LPTSTR UserName,LPTSTR Password);
extern "C" int __stdcall GetUserPassword(LPTSTR User,LPTSTR & pwd,int & length);
extern "C" int __stdcall UserDel(LPTSTR User);
extern "C" int __stdcall GetUser(int num,LPTSTR & name,int & length);
extern "C" int __stdcall EncryptDB(LPTSTR DBName,bool Flag);
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告