delphi 中的 WideString 对应VB 什么函数或类型?

seeQe 2011-04-15 05:41:45
有个DLL 中的函数原型:
extern "C" bool __declspec(dllexport) __stdcall EvideoOpenRoom(BSTR RoomIP, BSTR ServerIP, int iFlag)

用Delphi 调用时,能正确调用,具体如下:
声明:
function EvideoOpenRoom(RoomIP, ServerIP: WideString; iFlag: Integer): boolean;stdcall;
far;external 'SendWineEV.dll' name 'EvideoOpenRoom';

使用:
if EvideoOpenRoom(WideString(Edit2.Text), WideString(Edit1.Text), iFlag) then
begin
ShowMessage('发送指令成功');
end
end;

******************************************************************************************
如果使用VB 调用,无法正确执行
引用如下:
Public Declare Function EvideoOpenRoom Lib "SendWineEV.DLL" (ByVal strRoomIP As String, ByVal strServerIP As String, ByVal nFlag As Long) As Long

使用:
Private Sub btnOpenRoom_Click()
Dim nFlag As Long, nRet As Long
Dim strServerIP As String, strRoomIP As String

nFlag = 0
strRoomIP = Trim(Edit2.Text)
strServerIP = Trim(Edit1.Text)
nRet = EvideoOpenRoom(strRoomIP, strServerIP, nFlag)

End Sub

运行结果nRet = 0 也就是表示失败,产生动作效果也和dephi 中不同,不知道问题出在哪里,请高手指点,多谢多谢~~


...全文
167 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
seeQe 2011-07-26
  • 打赏
  • 举报
回复
使用BSTR 是个智能字符串,定义成 long 就行了,谢谢各位

EvideoOpenRoom( RoomIP as long, ServerIP as long , iFlag as integer)

shaoyy 2011-04-16
  • 打赏
  • 举报
回复
BSTR 是windows中不同进程共享字符信息的标准类型,一位字符占两个字节,我VB不太熟悉,我觉你可以在VB中引入任意一个含有BSTR类型参数的COM控件(我的AC Report中就有这种参数的方法),看一下系统转换为什么类型。
三断笛 2011-04-16
  • 打赏
  • 举报
回复
用strconv转化下?
捧剑者 2011-04-16
  • 打赏
  • 举报
回复
所以,widestring 与vb6中的string相同,但是在vb6调用api时,会自动将unicode转化为ansi。用byte数组可以避免这样的转换。
捧剑者 2011-04-16
  • 打赏
  • 举报
回复
The WideString type represents a dynamically allocated string of 16-bit Unicode characters. In most respects it is similar to AnsiString. On Win32, WideString is compatible with the COM BSTR type.
贝隆 2011-04-15
  • 打赏
  • 举报
回复
严格的说Delphi中的WideString在VB中无对应类型。
捧剑者 2011-04-15
  • 打赏
  • 举报
回复
试试:
Public Declare Function EvideoOpenRoom Lib "SendWineEV.DLL" (strRoomIP As Any, strServerIP As Any, ByVal nFlag As Long) As Long

Dim strServerIP() As byte, strRoomIP() As byte

7,763

社区成员

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

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