vb调用vc dll 参数为结构体 

springkid 2008-06-02 03:45:27
如果在vc.dll的参数是结构体:
typedef struct{
BYTE m_bRemoteChannel;
BYTE m_bSendMode;
BYTE m_nImgFormat;
char *m_sIPAddress;
char *m_sUserName;
char *m_sUserPassword;
BOOL m_bUserCheck;
HWND m_hShowVideo;
}CLIENT_VIDEOINFO, *PCLIENT_VIDEOINFO;

在vb6中调用dll时
指针参数应该如何如赋值呢????

Private Type CLIENT_VIDEOINFO
m_bRemoteChannel As Byte
m_bSendMode As Byte
m_bImgFormat As Byte
m_sIPAddress As String
m_sUserName As String
m_sUserPassword As String
m_bUserCheck As Long
m_hShowVideo As Long
End Type

Private Declare Function MP4_ClientStart Lib "hikclient.dll" (nClentInfo As CLIENT_VIDEOINFO, ByVal lpEnumFunc As Long) As Long
Dim CV As CLIENT_VIDEOINFO

Dim strUserName As String * 127
Dim strUserPassWord As String * 127
Dim strIPAddress As String
'
strUserName = "123"
strUserPassWord = "w"
strIPAddress = "192.168.52.218"

CV.m_bRemoteChannel = 0
CV.m_bSendMode = 0
CV.m_bUserCheck = 1
CV.m_sUserName = strUserName
CV.m_sUserPassword = strUserPassWord
CV.m_bImgFormat = 0
CV.m_sIPAddress = strIPAddress
CV.m_hShowVideo = Picture1.hWnd

调用dll函数一直不成功 

Ret = MP4_ClientStart(CV, 0&)

请问我该如何如处理!
...全文
183 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
BuilderEm 2008-06-03
  • 打赏
  • 举报
回复
接分的.
K行天下 2008-06-02
  • 打赏
  • 举报
回复
这个上google搜一下,还是有相关帖子的!
springkid 2008-06-02
  • 打赏
  • 举报
回复
请问 我在vb里 结构体的定义有没有错
还有赋值有没有问题
因是结构体在使用的时候出错了
请高手帮助 谢谢
  • 打赏
  • 举报
回复
参考一下OPENFILENAME这个结构体的使用方法


Private   Declare   Function   GetOpenFileName   Lib   "comdlg32.dll "   Alias   "GetOpenFileNameA "   (pOpenfilename   As   OPENFILENAME)   As   Long 
Private Declare Function GetSaveFileName Lib "comdlg32.dll " Alias "GetSaveFileNameA " (pOpenfilename As OPENFILENAME) As Long

Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

Public Function OpenFileDlg(hwnd As Long,Title as string) As String
Dim OFDlg As OPENFILENAME
With OFDlg
.lStructSize = Len(ofd)
.hwndOwner = hwnd
.hInstance = App.hInstance
.lpstrFilter = "*.* " + Chr$(0) + "*.* " + Chr$(0)
.lpstrFile = Space$(254)
.lpstrFileTitle = Space$(254)
.nMaxFile = 255
.nMaxFileTitle = 255
.lpstrInitialDir = CurDir
.lpstrTitle = title
.flags = 0
End With
If GetOpenFileName(ofd) Then OpenFileDlg = Left(OFDlg.lpstrFile, InStr(OFDlg.lpstrFile, Chr(0)) - 1)
End Function

Public Function SaveFileDlg(hwnd As long,Title as string) As String
Dim SFDlg As OPENFILENAME
With SFDlg
.lStructSize = Len(SFDlg)
.hwndOwner = hwnd
.hInstance = App.hInstance
.lpstrFile = Space(254)
.lpstrFileTitle = Space(254)
.nMaxFile = 255
.nMaxFileTitle = 255
.lpstrInitialDir = App.Path
.flags = 6148 Or &H2
.lpstrFilter = "*.* " + Chr$(0) + "*.* "
.lpstrTitle = title
If GetSaveFileName(SFDlg) > = 1 Then
SaveFileDlg = Left(.lpstrFile, InStr(.lpstrFile, Chr(0)) - 1)
End If
End With
End Function
springkid 2008-06-02
  • 打赏
  • 举报
回复
先谢谢!
CPLAYER_API LONG __stdcall MP4_ClientStart(PCLIENT_VIDEOINFO pClientinfo,void(CALLBACK *ReadDataCallBack)(DWORD nPort,UCHAR *pPacketBuffer,DWORD nPacketSize));

void CAaDlg::OnOK()
{
// TODO: Add extra validation here
CLIENT_VIDEOINFO dlg;
dlg.m_bRemoteChannel=0;
dlg.m_bSendMode=0;
dlg.m_bUserCheck=TRUE;
dlg.m_sUserName = "123";
dlg.m_sUserPassword="w";
dlg.m_nImgFormat=0;
dlg.m_sIPAddress="192.168.6.216";
dlg.m_hShowVideo=GetDlgItem(IDC_video)->GetSafeHwnd();
long a=MP4_ClientStart(&dlg,NULL);
}
这里是vc代码里面 dll里肯定有 别的初始化函数我都执行成功了!
长安宁 2008-06-02
  • 打赏
  • 举报
回复
你用 dumpbin export hikclient.dll 看一下,MP4_ClientStart,是不是,叫这个名字;
长安宁 2008-06-02
  • 打赏
  • 举报
回复
你用 dumpbin export vc.dll 看一下,MP4_ClientStart,是不是,叫这个名字;
有没有用 extern "C" {long __stdcall dllexport MP4_ClientStart(CLIENT_VIDEOINFO cv,long lpEnumFunc);}之类的东西;

再有Ret = MP4_ClientStart(CV, 0&)
里面的0&,哪里是 byval呀?

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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