当前位置:编程学习 > VB >>

API函数调用问题,请高手指教

我在模块里定义了这些函数,在窗口中如何调用?
'启动服务,打开串口,初始化Modem, 0为失败,非0为成功
'校验位, EvenParity :0,MarkParity:1,NoParity:2,OddParity:3,SpaceParity,4
'停止位 OneStopBit 0,OnePointFiveStopBits:1,TwoStopBits 2
'流控:NoFlowControl:0,    CtsRtsFlowControl:1,    CtsDtrFlowControl:2,    DsrRtsFlowControl:3,    DsrDtrFlowControl:4,    XonXoffFlowControl:5
'最后一个参数csca为短信中心号码,如果直接用卡内已存的短信中心号码则用"card"(小写)
Public Declare Function SMSStartService Lib "SMSDLL.dll" (ByVal nPort As Long, ByVal BaudRate As Long, ByVal Parity As Integer, ByVal DataBits As Integer, ByVal StopBits As Integer, ByVal FlowControl As Integer, ByVal csca As String) As Long


这样可以对吗?
SMSStartService 1, 115200, 2, 8, 0, 0, card

这个就不知道怎么调用了
Public Type SMSMessageStruct
    Msg(0 To 255) As Byte  '//短信内容
    PhoneNo(0 To 31) As Byte  '//对方手机号码
    ReceTime(0 To 31) As Byte  '//接收时间
End Type

Public Declare Function SMSGetNextMessage Lib "SMSDLL.dll" (ByRef smg As SMSMessageStruct) As Long

请高手指教,最好能给个源码,谢谢 这个是硬件配套的DLL文件,没有这个Dll文件,大家怎么帮你??? Public Type SMSMessageStruct
  Msg(0 To 255) As Byte '//短信内容
  PhoneNo(0 To 31) As Byte '//对方手机号码
  ReceTime(0 To 31) As Byte '//接收时间
End Type
****************
这个是自定义的数据类型 告诉我怎么去调用这些函数就可以了,API我用不来,就是VB窗口中有个COMMAND1 设为“启动” 在这按钮里,如何变成调用这个SMSStartService函数,急啊,跪求
引用楼主 ysk2006110 的回复:
这个就不知道怎么调用了
Public Type SMSMessageStruct
  Msg(0 To 255) As Byte '//短信内容
  PhoneNo(0 To 31) As Byte '//对方手机号码
  ReceTime(0 To 31) As Byte '//接收时间
End Type

Public Declare Function SMSGetNextMessage Lib "SMSDLL.dll" (ByRef smg As SMSMessageStruct) As Long

请高手指教,最好能给个源码,谢谢


定义一个数组转字符串函数'假设返回的是ansi编码
private function Conv(a() as byte)as string
dim i as long
for i=lbound(a) to ubound(a)
if a(i)=0 then
exit for
else
Conv=Conv & chr(a(i))
end if
next
end function

调用位置

dim a as SMSMessageStruct'定义一个结构
SMSGetNextMessage a

dim sContent as string
dim Phone as string
dim sTime as string

scontent=conv(a.msg)
Phone=conv(a.PhoneNum)
sTime=conv(a.recetime)
补充:VB ,  API
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,