Form1.frm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. VERSION 5.00
  2. Begin VB.Form Form1
  3. Caption = "梦网网关动态库演示程序"
  4. ClientHeight = 7875
  5. ClientLeft = 60
  6. ClientTop = 345
  7. ClientWidth = 6720
  8. FillColor = &H00FFFFFF&
  9. LinkTopic = "Form1"
  10. ScaleHeight = 7875
  11. ScaleWidth = 6720
  12. StartUpPosition = 3 'Windows Default
  13. Begin VB.TextBox TxtDetail
  14. Height = 975
  15. Left = 120
  16. MultiLine = -1 'True
  17. ScrollBars = 2 'Vertical
  18. TabIndex = 40
  19. Top = 6840
  20. Width = 6495
  21. End
  22. Begin VB.Frame Frame5
  23. Caption = "提示信息"
  24. Height = 1575
  25. Left = 105
  26. TabIndex = 38
  27. Top = 5160
  28. Width = 6495
  29. Begin VB.ListBox LstInfo
  30. Height = 1230
  31. ItemData = "Form1.frx":0000
  32. Left = 60
  33. List = "Form1.frx":0002
  34. TabIndex = 39
  35. Top = 225
  36. Width = 6330
  37. End
  38. End
  39. Begin VB.Frame Frame4
  40. Caption = "帐户管理"
  41. Height = 690
  42. Left = 105
  43. TabIndex = 32
  44. Top = 4440
  45. Width = 6495
  46. Begin VB.CommandButton CmdUsed
  47. Caption = "查询使用"
  48. Height = 345
  49. Left = 195
  50. TabIndex = 35
  51. Top = 240
  52. Width = 1230
  53. End
  54. Begin VB.CommandButton CmdChangePwd
  55. Caption = "修改密码"
  56. Height = 345
  57. Left = 3105
  58. TabIndex = 34
  59. Top = 240
  60. Width = 1230
  61. End
  62. Begin VB.CommandButton CmdLeft
  63. Caption = "查询余额"
  64. Height = 345
  65. Left = 1635
  66. TabIndex = 33
  67. Top = 240
  68. Width = 1230
  69. End
  70. Begin VB.TextBox TxtNewPwd
  71. Height = 375
  72. Left = 5340
  73. TabIndex = 36
  74. Top = 225
  75. Width = 975
  76. End
  77. Begin VB.Label Label11
  78. Caption = "新密码:"
  79. Height = 255
  80. Left = 4515
  81. TabIndex = 37
  82. Top = 300
  83. Width = 795
  84. End
  85. End
  86. Begin VB.Frame Frame3
  87. Caption = "信息操作"
  88. Height = 2490
  89. Left = 105
  90. TabIndex = 16
  91. Top = 1890
  92. Width = 6510
  93. Begin VB.CommandButton CmdReprot
  94. Caption = "状态报告"
  95. Enabled = 0 'False
  96. Height = 375
  97. Left = 4950
  98. TabIndex = 31
  99. Top = 2025
  100. Width = 1440
  101. End
  102. Begin VB.CommandButton CmdRecv
  103. Caption = "接收信息"
  104. Enabled = 0 'False
  105. Height = 375
  106. Left = 4950
  107. TabIndex = 30
  108. Top = 1575
  109. Width = 1440
  110. End
  111. Begin VB.CommandButton CmdSend
  112. Caption = "单向信息"
  113. Height = 375
  114. Left = 4950
  115. TabIndex = 29
  116. Top = 1125
  117. Width = 1440
  118. End
  119. Begin VB.TextBox TxtMsg
  120. Height = 1305
  121. Left = 885
  122. MultiLine = -1 'True
  123. ScrollBars = 2 'Vertical
  124. TabIndex = 28
  125. Text = "Form1.frx":0004
  126. Top = 1080
  127. Width = 3585
  128. End
  129. Begin VB.TextBox TxtCount
  130. Height = 375
  131. Left = 5415
  132. TabIndex = 25
  133. Top = 630
  134. Width = 975
  135. End
  136. Begin VB.TextBox TxtLinkid
  137. Height = 375
  138. Left = 4545
  139. TabIndex = 23
  140. Top = 180
  141. Width = 1860
  142. End
  143. Begin VB.TextBox TxtFee
  144. Height = 375
  145. Left = 3075
  146. TabIndex = 21
  147. Top = 180
  148. Width = 795
  149. End
  150. Begin VB.TextBox TxtSport
  151. Height = 375
  152. Left = 885
  153. TabIndex = 18
  154. Top = 180
  155. Width = 1350
  156. End
  157. Begin VB.TextBox TxtPhone
  158. Height = 375
  159. Left = 885
  160. TabIndex = 17
  161. Text = "13534***346"
  162. Top = 615
  163. Width = 3585
  164. End
  165. Begin VB.Label Label10
  166. Caption = "短信内容:"
  167. Height = 225
  168. Left = 90
  169. TabIndex = 27
  170. Top = 1050
  171. Width = 870
  172. End
  173. Begin VB.Label Label9
  174. Caption = "手机个数:"
  175. Height = 255
  176. Left = 4590
  177. TabIndex = 26
  178. Top = 690
  179. Width = 795
  180. End
  181. Begin VB.Label Label8
  182. Caption = "匹配码:"
  183. Height = 255
  184. Left = 3945
  185. TabIndex = 24
  186. Top = 240
  187. Width = 585
  188. End
  189. Begin VB.Label Label7
  190. Caption = "费率代码:"
  191. Height = 255
  192. Left = 2295
  193. TabIndex = 22
  194. Top = 270
  195. Width = 765
  196. End
  197. Begin VB.Label Label1
  198. Caption = "端口号码:"
  199. Height = 255
  200. Left = 90
  201. TabIndex = 20
  202. Top = 240
  203. Width = 795
  204. End
  205. Begin VB.Label Label2
  206. Caption = "手机号码:"
  207. Height = 255
  208. Left = 75
  209. TabIndex = 19
  210. Top = 660
  211. Width = 870
  212. End
  213. End
  214. Begin VB.Frame Frame2
  215. Caption = "帐户登陆"
  216. Height = 1200
  217. Left = 105
  218. TabIndex = 4
  219. Top = 675
  220. Width = 6510
  221. Begin VB.CommandButton CdTest
  222. Caption = "测试连接"
  223. Height = 375
  224. Left = 4815
  225. TabIndex = 15
  226. Top = 675
  227. Width = 1590
  228. End
  229. Begin VB.CommandButton CdDisConn
  230. Caption = "断开"
  231. Enabled = 0 'False
  232. Height = 375
  233. Left = 5670
  234. TabIndex = 14
  235. Top = 180
  236. Width = 735
  237. End
  238. Begin VB.CommandButton CdConn
  239. Caption = "连接"
  240. Default = -1 'True
  241. Height = 375
  242. Left = 4815
  243. TabIndex = 13
  244. Top = 180
  245. Width = 735
  246. End
  247. Begin VB.TextBox TxAccount
  248. Height = 375
  249. Left = 765
  250. MaxLength = 30
  251. TabIndex = 10
  252. Text = "13600000412"
  253. Top = 660
  254. Width = 2055
  255. End
  256. Begin VB.TextBox TxPassword
  257. Height = 375
  258. IMEMode = 3 'DISABLE
  259. Left = 3615
  260. PasswordChar = "*"
  261. TabIndex = 9
  262. Text = "800000"
  263. Top = 660
  264. Width = 840
  265. End
  266. Begin VB.TextBox TxServer
  267. Height = 375
  268. Left = 765
  269. MaxLength = 30
  270. TabIndex = 6
  271. Text = "61.242.89.115"
  272. Top = 240
  273. Width = 2055
  274. End
  275. Begin VB.TextBox TxPort
  276. Height = 375
  277. IMEMode = 3 'DISABLE
  278. Left = 3615
  279. TabIndex = 5
  280. Text = "8018"
  281. Top = 240
  282. Width = 840
  283. End
  284. Begin VB.Label Label6
  285. Caption = "帐号:"
  286. Height = 255
  287. Left = 120
  288. TabIndex = 12
  289. Top = 735
  290. Width = 555
  291. End
  292. Begin VB.Label Label5
  293. Caption = "密码:"
  294. Height = 255
  295. Left = 3060
  296. TabIndex = 11
  297. Top = 735
  298. Width = 525
  299. End
  300. Begin VB.Label Label3
  301. Caption = "服务器:"
  302. Height = 255
  303. Left = 120
  304. TabIndex = 8
  305. Top = 315
  306. Width = 615
  307. End
  308. Begin VB.Label Label4
  309. Caption = "端口:"
  310. Height = 255
  311. Left = 3060
  312. TabIndex = 7
  313. Top = 315
  314. Width = 525
  315. End
  316. End
  317. Begin VB.Frame Frame1
  318. Caption = "帐户类型"
  319. Height = 615
  320. Left = 105
  321. TabIndex = 0
  322. Top = 15
  323. Width = 6525
  324. Begin VB.CheckBox CkKf
  325. Caption = "客服双向帐户"
  326. Height = 255
  327. Left = 4830
  328. TabIndex = 3
  329. Top = 225
  330. Width = 1545
  331. End
  332. Begin VB.CheckBox CkVas
  333. Caption = "增值双向帐户"
  334. Height = 255
  335. Left = 2325
  336. TabIndex = 2
  337. Top = 240
  338. Width = 1770
  339. End
  340. Begin VB.CheckBox CkSingle
  341. Caption = "单向帐户"
  342. Height = 255
  343. Left = 240
  344. TabIndex = 1
  345. Top = 240
  346. Value = 1 'Checked
  347. Width = 1710
  348. End
  349. End
  350. End
  351. Attribute VB_Name = "Form1"
  352. Attribute VB_GlobalNameSpace = False
  353. Attribute VB_Creatable = False
  354. Attribute VB_PredeclaredId = True
  355. Attribute VB_Exposed = False
  356. Private Declare Function MongateConnect Lib "MWGateway.dll" (ByVal serverip As String, _
  357. ByVal port As Integer, ByVal account As String, ByVal pwd As String) As Integer
  358. Private Declare Function MongateSendSms Lib "MWGateway.dll" (ByVal socket As Integer, _
  359. ByVal mobi As String, ByVal msg As String) As Integer
  360. Private Declare Function MongateTestConn Lib "MWGateway.dll" (ByVal socket As Integer) As Integer
  361. Private Declare Function MongateQueryBalance Lib "MWGateway.dll" (ByVal socket As Integer) As Long
  362. Private Declare Function MongateQueryUsed Lib "MWGateway.dll" (ByVal socket As Integer) As Integer
  363. Private Declare Function MongateRecharge Lib "MWGateway.dll" (ByVal socket As Integer, _
  364. ByVal cardno As String, ByVal cardpwd As String) As Integer
  365. Private Declare Function MongateChangePwd Lib "MWGateway.dll" (ByVal socket As Integer, _
  366. ByVal account As String, ByVal oldpwd As String, ByVal newpwd As String) As Integer
  367. Private Declare Sub MongateDisconnect Lib "MWGateway.dll" (ByVal socket As Integer)
  368. Private Declare Function MongateVasGetSms Lib "MWGateway.dll" (ByVal socket As Integer, _
  369. ByRef recvmsg As Byte) As Integer
  370. Private Declare Function MongateVasSendSms Lib "MWGateway.dll" (ByVal socket As Integer, _
  371. ByVal feecode As String, ByVal spno As String, ByVal opercode As String, _
  372. ByVal linkid As String, ByVal mobis As String, ByVal msg As String, _
  373. ByVal icount As Long) As Integer
  374. Private Declare Function MongateCsGetSms Lib "MWGateway.dll" (ByVal socket As Integer, _
  375. ByRef statereport As Byte) As Integer
  376. Private Declare Function MongateCsSendSms Lib "MWGateway.dll" (ByVal socket As Integer, _
  377. ByVal mobi As String, ByVal note As String, ByVal icount As Long, _
  378. ByRef msgno As Byte) As Integer
  379. Private Declare Function MongateCsGetStatusReport Lib "MWGateway.dll" _
  380. (ByVal socket As Integer, ByRef recvmsg As Byte) As Integer
  381. Dim clientsock As Long
  382. Private Sub CdConn_Click()
  383. If (clientsock <= 0) Then
  384. clientsock = MongateConnect(Trim(TxServer.Text), CInt(Trim(TxPort.Text)), _
  385. Trim(TxAccount.Text), Trim(TxPassword.Text))
  386. If (clientsock > 0) Then
  387. LstInfo.AddItem ("连接成功,句柄:" & clientsock)
  388. CdConn.Enabled = False
  389. CdDisConn.Enabled = True
  390. Else
  391. LstInfo.AddItem ("连接失败,返回:" & clientsock)
  392. End If
  393. End If
  394. End Sub
  395. Private Sub CdDisConn_Click()
  396. If (clientsock > 0) Then
  397. MongateDisconnect clientsock
  398. LstInfo.AddItem ("断开连接,句柄:" + CStr(clientsock))
  399. clientsock = 0
  400. CdConn.Enabled = True
  401. CdDisConn.Enabled = False
  402. End If
  403. End Sub
  404. Private Sub CdTest_Click()
  405. If Noconn Then Exit Sub
  406. Dim retu_state As Integer
  407. If (clientsock > 0) Then
  408. retu_state = MongateTestConn(clientsock)
  409. If retu_state = 1 Then
  410. LstInfo.AddItem ("测试连接成功")
  411. Else
  412. LstInfo.AddItem ("测试连接失败")
  413. clientsock = 0
  414. CdConn.Enabled = True
  415. CdDisConn.Enabled = False
  416. End If
  417. End If
  418. End Sub
  419. Function Noconn() As Boolean
  420. Noconn = False
  421. If clientsock <= 0 Then
  422. LstInfo.AddItem ("没有连接到任何服务器!!!")
  423. Noconn = True
  424. End If
  425. End Function
  426. Private Sub CkKf_Click()
  427. CkClick 2
  428. End Sub
  429. Private Sub CkSingle_Click()
  430. CkClick 0
  431. End Sub
  432. Private Sub CkVas_Click()
  433. CkClick 1
  434. End Sub
  435. Private Sub CkClick(ByVal seltype As Integer)
  436. If seltype = 0 Then
  437. If CkSingle.Value Then
  438. CkVas.Value = 0
  439. CkKf.Value = 0
  440. End If
  441. ElseIf seltype = 1 Then
  442. If CkVas.Value Then
  443. CkSingle.Value = 0
  444. CkKf.Value = 0
  445. End If
  446. Else
  447. If CkKf.Value Then
  448. CkVas.Value = 0
  449. CkSingle.Value = 0
  450. End If
  451. End If
  452. Showme TxtSport, CkVas.Value
  453. Showme TxtFee, CkVas.Value
  454. Showme TxtLinkid, CkVas.Value
  455. Showme TxtCount, (CkVas.Value Or CkKf.Value)
  456. CmdRecv.Enabled = CkVas.Value Or CkKf.Value
  457. CmdReprot.Enabled = CkKf.Value
  458. If CkVas.Value Then
  459. CmdSend.Caption = "增值信息"
  460. ElseIf CkKf.Value Then
  461. CmdSend.Caption = "客服信息"
  462. Else
  463. CmdSend.Caption = "单向信息"
  464. End If
  465. End Sub
  466. Private Sub Showme(edtmp As TextBox, flag As Boolean)
  467. edtmp.Enabled = flag
  468. If flag Then
  469. edtmp.BackColor = &H80000005
  470. Else
  471. edtmp.BackColor = &H8000000F
  472. End If
  473. End Sub
  474. Private Sub CmdChangePwd_Click()
  475. If Noconn Then Exit Sub
  476. Dim myfee As Integer
  477. Dim myip As String, myport As String
  478. If (clientsock > 0) Then
  479. myfee = MongateChangePwd(clientsock, Trim(TxAccount.Text), _
  480. Trim(TxPassword.Text), Trim(TxtNewPwd.Text))
  481. If (myfee = 1) Then
  482. LstInfo.AddItem ("修改密码成功,请记住新密码")
  483. Else
  484. LstInfo.AddItem ("修改密码失败")
  485. End If
  486. End If
  487. End Sub
  488. Private Sub CmdLeft_Click()
  489. If Noconn Then Exit Sub
  490. Dim myfee As Long
  491. Dim myip As String, myport As String
  492. If (clientsock > 0) Then
  493. myfee = MongateQueryBalance(clientsock)
  494. If (myfee >= 0) Then
  495. LstInfo.AddItem ("查询余额成功" & myfee)
  496. Else
  497. LstInfo.AddItem ("查询余额失败" & myfee)
  498. End If
  499. End If
  500. End Sub
  501. Private Sub CmdRecv_Click()
  502. If Noconn Then Exit Sub
  503. Dim recv(254, 500) As Byte
  504. Dim buf(255) As Byte
  505. Dim Str As String
  506. Dim num As Integer
  507. Dim i As Integer
  508. Dim k As Integer
  509. If (clientsock > 0) Then
  510. If CkKf.Value Then
  511. num = MongateCsGetSms(clientsock, recv(0, 0))
  512. Else
  513. num = MongateVasGetSms(clientsock, recv(0, 0))
  514. End If
  515. If (num > 0) Then
  516. For i = 0 To num - 1
  517. For k = 0 To 254
  518. buf(k) = recv(k, i)
  519. If (buf(k) = 0) Then
  520. Exit For
  521. End If
  522. Next
  523. Str = StrConv(buf(), vbUnicode)
  524. LstInfo.AddItem ("接收信息:" & Str)
  525. Next
  526. Else
  527. LstInfo.AddItem ("接收无信息")
  528. End If
  529. End If
  530. End Sub
  531. Private Sub CmdReprot_Click()
  532. If Noconn Then Exit Sub
  533. Dim recv(254, 500) As Byte
  534. Dim buf(255) As Byte
  535. Dim Str As String
  536. Dim num As Integer
  537. Dim i As Integer
  538. Dim k As Integer
  539. If (clientsock > 0) Then
  540. num = MongateCsGetStatusReport(clientsock, recv(0, 0))
  541. If (num > 0) Then
  542. For i = 0 To num - 1
  543. For k = 0 To 254
  544. buf(k) = recv(k, i)
  545. If (buf(k) = 0) Then
  546. Exit For
  547. End If
  548. Next
  549. Str = StrConv(buf(), vbUnicode)
  550. LstInfo.AddItem ("状态报告:" & Str)
  551. Next
  552. Else
  553. LstInfo.AddItem ("无状态报告")
  554. End If
  555. End If
  556. End Sub
  557. Private Sub CmdSend_Click()
  558. If Noconn Then Exit Sub
  559. Dim retu_state As Long, icount As Integer
  560. Dim retu_msgnumber(40) As Byte
  561. If Noconn Then Exit Sub
  562. If Trim(TxtCount.Text) = "" Then
  563. icount = 1
  564. Else
  565. icount = CInt(TxtCount.Text)
  566. End If
  567. If CkVas.Value Then '//增值信息
  568. retu_state = MongateVasSendSms(clientsock, Trim(TxtFee.Text), _
  569. Trim(TxtSport.Text), "00********", Trim(TxtLinkid.Text), _
  570. Trim(TxtPhone.Text), Trim(TxtMsg.Text), icount)
  571. If (retu_state = 1) Then
  572. LstInfo.AddItem ("发送增值信息成功!")
  573. Else
  574. LstInfo.AddItem ("发送增值信息失败!返回:" + CStr(retu_state))
  575. End If
  576. ElseIf CkKf.Value Then '//客服信息
  577. retu_state = MongateCsSendSms(clientsock, Trim(TxtPhone.Text), _
  578. Trim(TxtMsg.Text), icount, retu_msgnumber(0))
  579. If (retu_state = 1) Then
  580. LstInfo.AddItem ("发送客服信息成功!信息编号:" + StrConv(retu_msgnumber(), vbUnicode))
  581. Else
  582. LstInfo.AddItem ("发送客服信息失败!返回:" + CStr(retu_state))
  583. End If
  584. Else '单向信息
  585. retu_state = MongateSendSms(clientsock, TxtPhone.Text, TxtMsg.Text)
  586. If (retu_state = 1) Then
  587. LstInfo.AddItem ("发送单向信息成功")
  588. Else
  589. LstInfo.AddItem ("发送单向信息失败!返回:" + CStr(retu_state))
  590. End If
  591. End If
  592. End Sub
  593. Private Sub CmdUsed_Click()
  594. If Noconn Then Exit Sub
  595. Dim myfee As Integer
  596. If (clientsock > 0) Then
  597. myfee = MongateQueryUsed(clientsock)
  598. If (myfee >= 0) Then
  599. LstInfo.AddItem ("查询使用成功" & myfee)
  600. Else
  601. LstInfo.AddItem ("查询使用失败" & myfee)
  602. End If
  603. End If
  604. End Sub
  605. Private Sub Form_Load()
  606. clientsock = 0
  607. CkClick 0
  608. End Sub
  609. Private Sub LstInfo_Click()
  610. TxtDetail.Text = LstInfo.Text
  611. End Sub