VB/vb.net 浙江移动发送手机短信实例!!!!!!!!!!!!!!!!!!!!!!!(原创)

类别:.NET开发 点击:0 评论:0 推荐:

浙江移动发送手机短信实例!!!!!!!!!!!!!!!!!!!!!!!

'****************************************************************************
'Form1 窗体
Dim userID As String
Dim mobileNo As String
Dim checkRnd As String
Dim longin As Boolean
Dim checkRndBox As String
Public fileno As Variant
Dim ys As Integer
Dim su As Long
Dim sum As Long
Dim pas As String


Private Sub Check2_Click()
On Error GoTo err1
If Check2.Value Then
Open App.Path & "\" & Text9.Text For Input As #fileno

Else
Close #fileno
End If
Exit Sub
err1:
Stop
 MsgBox "打开文件出错"
End Sub

Private Sub Command1_click()
On Error Resume Next
    Dim allCol
    Dim TagName As String
    Dim allcount, i
    Label2.Caption = "准备读取数据"
    Set allCol = WebBrowser1.Document.All
    allcount = allCol.length
  For i = 0 To allcount - 1
    TagName = allCol.Item(i).TagName
    If "INPUT" = TagName Then
      TagName = allCol.Item(i).Name
      Select Case TagName
        Case "userID"
             userID = allCol.Item(i).Value
        Case "mobileNo"
             mobileNo = allCol.Item(i).Value
      End Select
       End If
    Next
    Timer5.Enabled = True
    Exit Sub
End Sub
Private Sub Command2_Click()
Timer5.Enabled = True
End Sub

Private Sub Command3_Click()
    Dim deskhdc&, ret&
    Dim pxy As POINTAPI
    deskhdc = GetDC(0)
    pxy.x = Me.Left / Screen.TwipsPerPixelX + Picture1.Left
    pxy.Y = Me.Top / Screen.TwipsPerPixelY + Picture1.Top + 17 + Val(Text1.Text)
    deskhdc = BitBlt(Picture2.hdc, 0, 0, Picture1.Width + Val(Text3.Text), Picture1.Height + 6, deskhdc, pxy.x, pxy.Y, vbSrcCopy)
'    Stop
    ret = ReleaseDC(0&, deskhdc)
    Picture2.Refresh
   
End Sub

Private Sub Command4_Click()
    Dim i As Double
    Dim Y As Integer
    Dim deskhdc&, ret&
    Dim pxy As POINTAPI
     Dim pxy1 As POINTAPI
   Dim pxy2 As POINTAPI
    deskhdc = GetDC(0)
    pxy.x = Me.Left / Screen.TwipsPerPixelX + Picture1.Left
    pxy.Y = Me.Top / Screen.TwipsPerPixelY + Picture1.Top + 17
    pxy1.x = Me.Left / Screen.TwipsPerPixelX + Picture1.Width + 5 + Picture1.Left
    i = (pxy1.x - pxy.x) / 4
   Select Case Val(Text1.Text)
    Case 0
       deskhdc = BitBlt(Picture2.hdc, 0, 0, i, Picture1.Height + 6, deskhdc, pxy.x + 2, pxy.Y, vbSrcCopy)
    Case 1
       deskhdc = BitBlt(Picture2.hdc, 0, 0, i, Picture1.Height + 6, deskhdc, pxy.x + i + 1, pxy.Y, vbSrcCopy)
    Case 2
       deskhdc = BitBlt(Picture2.hdc, 0, 0, i, Picture1.Height + 6, deskhdc, pxy.x + i * 2 + 1, pxy.Y, vbSrcCopy)
    Case 3
       pxy1.x = Me.Left / Screen.TwipsPerPixelX + Picture1.Width + Picture1.Left
       i = (pxy1.x - pxy.x) / 4
       deskhdc = BitBlt(Picture2.hdc, 0, 0, i + 2, Picture1.Height + 6, deskhdc, pxy.x + i * 3 + 3.5, pxy.Y, vbSrcCopy)
   End Select
    ret = ReleaseDC(0&, deskhdc)
    Picture2.Refresh
   
End Sub

Private Sub Command5_Click()
Dim x1, y1 As Integer
Dim i  As Integer
Dim h As Integer
Dim s As Long
Dim mu As Long
y1 = Picture2.ScaleHeight
'y2 = y1 * 7
x1 = Picture2.ScaleWidth
'x2 = x1 * 8
'================
    For i = 1 To x1
    For h = 1 To y1
    DoEvents
         ' Stop
         '8396800
          If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
            s = s + 1
        End If
           Next h
    Next i

   Select Case s
  
'1   30
'2   36
'3   36
'4   36
'5   31
'6   43
'7   23 24
'8   47
'9   42
'0   42
    Case 20
       mu = 2
    Case 30
      s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
         If s = 25 Then
         mu = 5
         Else
         mu = 1
         End If
    Case 33, 14
     mu = 3
    Case 35
    s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
         If s = 22 Then
          mu = 2
         ElseIf s = 35 Then
         mu = 6
         ElseIf s = 26 Then
         mu = 5
         Else
      mu = 4
      End If
    Case 36
       s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
         If s = 22 Then
          mu = 2
        ElseIf s = 32 Then
         mu = 4
         Else
         mu = 3
        End If
    Case 31, 26
     s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
        If s = 23 Then mu = 1 Else mu = 5
     
    Case 37, 29
     mu = 3
    Case 43
      mu = 6
    Case 34
     s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
        If s = 36 Then
        mu = 6
       
        ElseIf s = 22 Then
        mu = 2
        Else
        mu = 0
        End If
    Case 22, 23, 24, 25, 16
      mu = 7
    Case 47, 50, 45
      mu = 8
    Case 42
      s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
         If s = 37 Then
          mu = 9
        Else
         mu = 0
        End If
    Case 40, 41
        mu = 9
    Case 21
        s = 0
       For i = 1 To x1
         For h = 1 To y1 / 5 * 3
        DoEvents
         ' Stop
         '8396800
                If 0 = GetPixel(Me.Picture2.hdc, i, h) Then
                    s = s + 1
                End If
                  Next h
         Next i
         If s = 21 Then
          mu = 2
         Else
        mu = 4
        End If
    Case Else
    End Select
   
    pas = Trim(pas & mu)
    Debug.Print s & ": " & mu
End Sub

Private Sub Command6_Click()
 Dim width5  As Long, heigh5 As Long, rgb5 As Long
    Dim hdc5 As Long, i As Long, j As Long
    Dim bBlue As Long, bRed As Long, bGreen As Long
    Dim Y As Long

    width5 = Picture2.ScaleWidth
    heigh5 = Picture2.ScaleHeight
    hdc5 = Picture2.hdc
    For i = 1 To width5
        For j = 1 To heigh5
            rgb5 = GetPixel(hdc5, i, j)
          '  bBlue = Blue(rgb5)      '获得兰色值
          '  bRed = Red(rgb5)        '获得红色值
          '  bGreen = Green(rgb5)    '获得绿色值
            '将三原色转换为灰度
          '  Y = (9798 * bRed + 19235 * bGreen + 3735 * bBlue) \ 32768
            '将灰度转换为RGB
'           rgb5 = RGB(Y, Y, Y)
           
            If rgb5 > RGB(130, 130, 130) Then
            rgb5 = RGB(255, 255, 255)
            Else
            rgb5 = RGB(0, 0, 0)
            End If
            SetPixelV hdc5, i, j, rgb5
        Next j
    Next i
    Set Picture2.Picture = Picture2.Image
End Sub

Private Sub Command7_Click()
thd
End Sub

Private Sub Command8_Click()
Timer3.Enabled = True
End Sub

Private Sub Command9_Click()
Dim x1, y1 As Integer
Dim i  As Integer
Dim h As Integer
Dim s As Long
Dim mu As Long
s = 0
y1 = Picture2.ScaleHeight
x1 = Picture2.ScaleWidth
    For i = 1 To x1
    For h = 1 To y1 / 5 * 3
    DoEvents
          If Val(Text5.Text) = GetPixel(Me.Picture2.hdc, i, h) Then
            s = s + 1
        End If
           Next h
    Next i
    Me.Caption = s
End Sub

Private Sub Form_Load()
On Error Resume Next
fileno = FreeFile
SMonth.Text = Val(Format$(Now, "mm"))
Me.SDay.Text = Val(Format$(Now, "dd"))
Me.SHour.Text = Val(Format$(Now, "hh"))
Me.SMinute.Text = Val(Format$(Now, "nn"))
EnableWindow Picture1.hwnd, 0
 VScroll1.Value = WebBrowser1.Top
 Text10.Text = WebBrowser1.Top
'Me.Caption = App.Path
End Sub

Private Sub List1_Click()

End Sub

Private Sub Picture2_DragDrop(Source As Control, x As Single, Y As Single)
Picture3.BackColor = GetPixel(Picture2.hdc, x, Y)
End Sub

Private Sub Picture2_DragOver(Source As Control, x As Single, Y As Single, State As Integer)
Picture3.BackColor = GetPixel(Picture2.hdc, x, Y)
End Sub

Private Sub Picture3_DragDrop(Source As Control, x As Single, Y As Single)
Picture3.BackColor = GetDcColor()
Text5.Text = GetDcColor()
End Sub

Private Sub Picture3_DragOver(Source As Control, x As Single, Y As Single, State As Integer)
Picture3.BackColor = GetDcColor()
Text5.Text = GetDcColor()
End Sub

Public Function GetDcColor() As Double
Dim deskhdc&, ret&
Dim pxy As POINTAPI
    ' Get Desktop DC
    deskhdc = GetDC(0)
    'Get mouse position
    GetCursorPos pxy
    GetDcColor = GetPixel(deskhdc, pxy.x, pxy.Y)  'GetCursorPos(Pxy.X), GetCursorPos(Pxy.Y))
    ret& = ReleaseDC(0&, deskhdc)
End Function

Private Sub Text10_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
   WebBrowser1.Top = Val(Text10.Text)
End If
End Sub

Private Sub Text2_Change()
Label2.Caption = "内容长度:" & Len(Text2.Text)
End Sub

Private Sub Timer1_Timer()
Dim lu As Long
Dim CurrentTick   As Double
Dim doc, objhtml As Object
Dim i As Integer
Dim strhtml As String
If Not Me.WebBrowser1.Busy Then
Set doc = WebBrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
    On Error Resume Next
    Dim allCol
    Dim TagName As String
    Dim allcount
    Label2.Caption = "准备读取数据"
    Set allCol = WebBrowser1.Document.All
    allcount = allCol.length
    Text4.Text = objhtml.htmltext
    If Not longin Then
        lu = InStr(Text4.Text, "用户登陆")
        If lu <> 0 Then
    '登陆未成功
        Me.Label2.Caption = "用户密码出错"
        Exit Sub
        Else
    '登陆成功
        longin = True
        Label2.Caption = "登陆成功"
       
        End If
       
    End If
   
   CurrentTick = GetTickCount()
   Do
    DoEvents
   Loop While GetTickCount - 100 < CurrentTick
    'Command1_click
   
  For i = 0 To allcount - 1
    TagName = allCol.Item(i).TagName
    If "INPUT" = TagName Then
      TagName = allCol.Item(i).Name
      Select Case TagName
        Case "userID"
             userID = allCol.Item(i).Value
        Case "mobileNo"
             mobileNo = allCol.Item(i).Value
      End Select
       End If
    Next
 '  Debug.Print userID & mobileNo
    pas = ""
        su = 0
        ys = 0
    Timer5.Enabled = True
    Timer2.Enabled = False
    ' checkRnd
   
    Timer1.Enabled = False
End If
End If
End Sub

Private Sub Timer2_Timer()
Dim lu As Long
Dim doc, objhtml As Object
Dim i As Integer
Dim strhtml As String

If Not Me.WebBrowser1.Busy Then
Set doc = WebBrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
   
    Text4.Text = objhtml.htmltext
'    Stop
 '   MsgBox Text4.Text
    lu = InStr(Text4.Text, "短信发送成功")
    If lu <> 0 Then
     Label2.Caption = "信息发送成功"
     If Check1.Value = Checked Then
     If Val(Text12.Text) < 2 Then
      接收手机号码.Text = Val(接收手机号码.Text) + 1
     Else
    接收手机号码.Text = Val(接收手机号码.Text) + Val(Text12.Text)
     End If
     If Val(接收手机号码.Text) > Val(Me.Text7.Text) Then Check1.Value = Unchecked
     End If
    
     If Val(Trim$(Text12.Text)) > 1 Then
     For i = 1 To Val(Text12.Text)
     Me.List1.AddItem (Me.List1.ListCount + 1) & ": " & Val(接收手机号码.Text) - Val(Text12.Text) + i & "     " & "成功"
     Me.List1.Selected(Me.List1.ListCount - 1) = True
     Next i
     Else
     Me.List1.AddItem (Me.List1.ListCount + 1) & ": " & Val(接收手机号码.Text) & "     " & "成功"
     Me.List1.Selected(Me.List1.ListCount - 1) = True
     End If
     '____________________________________
    
     Me.WebBrowser1.Navigate "http://211.140.32.131//MsgSendChoose.jsp?zmccCatalog=0801"
     Timer1.Enabled = True
    Else
    Label2.Caption = "信息发送失败"
    Me.WebBrowser1.Navigate "http://211.140.32.131//MsgSendChoose.jsp?zmccCatalog=0801"
   Timer1.Enabled = True
   Timer5.Enabled = False
   Timer2.Enabled = False
   'If 号码重试.Value = vbChecked Then
   '  Call 发送_Click
   'End If
   ' Timer1.Enabled = True
    End If
   Timer2.Enabled = False
End If
End If
End Sub

Private Sub Timer3_Timer()
Timer3.Enabled = False
On Error Resume Next
If Not EOF(fileno) Then
   Line Input #fileno, myline
   Me.接收手机号码.Text = Trim(myline)
   Call 发送_Click
Else
   Me.Check2.Value = Unchecked
   Exit Sub
End If
End Sub
Private Sub Timer5_Timer()

Dim CurrentTick   As Double
If Check3.Value = vbChecked Then
    Text1.Text = su
    Command4_Click
    CurrentTick = GetTickCount()
    Do
        DoEvents
    Loop While GetTickCount - 100 < CurrentTick
    Command6_Click
    CurrentTick = GetTickCount()
    Do
        DoEvents
    Loop While GetTickCount - 100 < CurrentTick
    Command5_Click
    su = su + 1
    ys = ys + 1
Else
    ys = 4
    pas = Text8.Text
End If
If ys > 3 Then
  Timer5.Enabled = False
  Text8.Text = pas
  checkRndBox = Val(Text8.Text)
  Label2.Caption = "读取数据成功"
  '-------------------------------------------
  If Check1.Value = Checked Then 发送_Click
 
  If Check2.Value = Checked Then Timer3.Enabled = True
End If
End Sub

Private Sub Timer6_Timer()
Dim doc, objhtml As Object
If Not Me.WebBrowser1.Busy Then
'错误信息
Set doc = WebBrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
    Dim sd As String
    sd = objhtml.htmltext
    If InStr(sd, userName.Text) = 0 Then
        End
  ' MsgBox sd
    End If
    Timer6.Enabled = False
     Call 登陆_Click
  Timer1.Enabled = True
    'Call Command1_Click
End If
End If
End Sub

Private Sub userPass_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call 登陆_Click
Timer1.Enabled = True
Label2.Caption = "正在登陆..."
 
End If
End Sub

Private Sub VScroll1_Change()
WebBrowser1.Top = VScroll1.Value
Text10.Text = WebBrowser1.Top
End Sub

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
' Cancel = True
End Sub

Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
On Error Resume Next
ProgressBar1.Max = ProgressMax
ProgressBar1.Value = Progress

End Sub

Private Sub 登陆_Click()
Dim cParamName As String
Dim cParamFlavor As String
Dim cSeparator As String
Dim cPostData As String
ReDim aByte(0) As Byte
Dim edtPostData As String
Dim i As Integer
      cParamName = "userName="
      cParamFlavor = "userPass="
      cSeparator = "&"
      cPostData = cParamName & userName.Text _
         & cSeparator & cParamFlavor & userPass.Text & cSeparator & "refer=/MsgSendChoose.jsp?zmccCatalog=0801"
      PackBytes aByte(), cPostData

      For i = LBound(aByte) To UBound(aByte)
          edtPostData = edtPostData + Chr(aByte(i))
      Next
      Dim vPost As Variant
      vPost = aByte
      Dim vFlags As Variant
      Dim vTarget As Variant
      Dim vHeaders As Variant
      vHeaders = _
         "Content-Type: application/x-www-form-urlencoded" _
         + Chr(10) + Chr(13)
      Form1.WebBrowser1.Navigate "http://211.140.32.131//loginAction.do", _
         vFlags, vTarget, vPost, vHeaders
         ys = 0
          su = 0
pas = ""

End Sub

Private Sub 发送_Click()
  '  sum = sum + 1
    Dim st As String
    Dim cParamName As String
    Dim cParamFlavor As String
    Dim cSeparator As String
    Dim i As Integer
    Dim cPostData As String
    Dim edtPostData As String
    Dim cpara As String
    ReDim aByte(0) As Byte
    Dim sum1 As Double
    Dim cmode As String
 '  If (60 - Len(Trim$(Text2.Text))) >= 1 Then st = Space$(2 * (60 - Len(Trim$(Text2.Text))))
      Label2.Caption = "准备发送信息"
      DoEvents
      body.Text = URLEncode(Text2.Text & st)
      If Me.是否定时.Value Then
       cmode = "mode=1"
       Else
       cmode = "mode=0"
       End If
      '& mobileNo
     
     
      cSeparator = "&"
      If Val(Text12.Text) < 2 And Check1.Value <> vbChecked Then
'      Stop                                                                                                                            '-----(Len(Text2.Text) - 11)
      cPostData = "userID=" & userID & cSeparator & "mobileNo=" & mobileNo & cSeparator & "body=" & body.Text & cSeparator & "len=" & 10 & cSeparator & "destAddr2=" & 接收手机号码.Text _
         & cSeparator & "checkRndBox=" & Trim(Text8.Text) & cSeparator & cmode _
         & cSeparator & "year=2004" & cSeparator & "month=" & SMonth.Text & cSeparator & "day=" & SDay.Text & cSeparator & "hour=" & SHour.Text & cSeparator & "minute=" & SMinute.Text & cSeparator & cmode & cSeparator & "radiobutton=radiobutton" & cSeparator & "dx=" & cSeparator & "dx2="
      Else
      Dim st1 As String
      For i = 0 To Val(Text12.Text)
        st1 = st1 & (Val(接收手机号码.Text) + i) & ";"
      Next i
'      MsgBox Mid(st1, 1, Len(st1) - 1)
     
      'Stop
     
      cPostData = "userID=" & userID & cSeparator & "mobileNo=" & mobileNo & cSeparator & "body=" & body.Text & cSeparator & "len=" & (Len(Text2.Text) - 11) & cSeparator & "destAddr2=" & st1 _
         & cSeparator & "checkRndBox=" & Trim(Text8.Text) & cSeparator & cmode _
         & cSeparator & "year=2004" & cSeparator & "month=" & SMonth.Text & cSeparator & "day=" & SDay.Text & cSeparator & "hour=" & SHour.Text & cSeparator & "minute=" & SMinute.Text & cSeparator & cmode & cSeparator & "radiobutton=radiobutton" & cSeparator & "dx=" & cSeparator & "dx2="
     
      End If
 
      PackBytes aByte(), cPostData

      For i = LBound(aByte) To UBound(aByte)
          edtPostData = edtPostData + Chr(aByte(i))
      Next

      Dim vPost As Variant
      vPost = aByte
     ' Debug.Print cPostData
      Dim vFlags As Variant
      Dim vTarget As Variant
      Dim vHeaders As Variant
      vHeaders = _
        "Content-Type: application/x-www-form-urlencoded" _
         + Chr(10) + Chr(13)
     Me.WebBrowser1.Navigate "http://211.140.32.131//MsgSendChooseAction.do", _
         vFlags, vTarget, vPost, vHeaders
         Label2.Caption = "提交信息"
        Timer2.Enabled = True
        pas = ""
        su = 0
        ys = 0
        '*******************************
    '    If sum > 100 Then End
'         password.Text = ""
End Sub

'********************************************************
'Module1

Public Type POINTAPI
        x As Long
        Y As Long
End Type

Public Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Public Declare Function GetTickCount Lib "kernel32" () As Long

Public Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Public Const SRCCOPY = &HCC0020
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function SetPixelV Lib "gdi32" _
     (ByVal hdc As Long, ByVal x As Long, _
      ByVal Y As Long, ByVal crColor As Long) As Long
     
Private Declare Function CreateThread Lib "kernel32" (ByVal lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Private Declare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function SuspendThread Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private h1 As Integer, h2 As Integer, h3 As Integer
Private s_run4 As Boolean, s_run3 As Boolean, s_run2 As Boolean, s_run1 As Boolean

 

 

Public Function URLEncode(ByRef strURL As String) As String
Dim i As Long
Dim tempStr As String
For i = 1 To Len(strURL)
    If Asc(Mid(strURL, i, 1)) < 0 Then
       tempStr = "%" & Right(CStr(Hex(Asc(Mid(strURL, i, 1)))), 2)
       tempStr = "%" & Left(CStr(Hex(Asc(Mid(strURL, i, 1)))), Len(CStr(Hex(Asc(Mid(strURL, i, 1))))) - 2) & tempStr
       URLEncode = URLEncode & tempStr
    ElseIf (Asc(Mid(strURL, i, 1)) >= 65 And Asc(Mid(strURL, i, 1)) <= 90) Or (Asc(Mid(strURL, i, 1)) >= 97 And Asc(Mid(strURL, i, 1)) <= 122) Then
       URLEncode = URLEncode & Mid(strURL, i, 1)
    Else
       URLEncode = URLEncode & "%" & Hex(Asc(Mid(strURL, i, 1)))
    End If
    DoEvents
Next
End Function

Public Function URLDecode(ByRef strURL As String) As String
Dim i As Long
If InStr(strURL, "%") = 0 Then URLDecode = strURL: Exit Function
For i = 1 To Len(strURL)
    If Mid(strURL, i, 1) = "%" Then
       If Val("&H" & Mid(strURL, i + 1, 2)) > 127 Then
          URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, i + 1, 2) & Mid(strURL, i + 4, 2)))
          i = i + 5
       Else
          URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, i + 1, 2)))
          i = i + 2
       End If
    Else
       URLDecode = URLDecode & Mid(strURL, i, 1)
    End If
    DoEvents
Next
End Function

Public Sub PackBytes(ByteArray() As Byte, ByVal PostData As String)
    Dim iNewBytes   As Long
      iNewBytes = Len(PostData) - 1
      If iNewBytes < 0 Then
       Exit Sub
      End If
      ReDim ByteArray(iNewBytes)
      For i = 0 To iNewBytes
       ch = Mid(PostData, i + 1, 1)
       DoEvents
       If ch = Space(1) Then
          ch = "+"
       End If
      ByteArray(i) = Asc(ch)
      Next
End Sub

上面已经是完成程序代码,,,,因为以前代码经常在改动,,部分代码没有用,,,请大家自己改写!!!!!!!
大家在浙江移动注册用户名,,可以用这个程序发信息了,,,,上面还有网页图片数字识别!!!!!供大家参考!!!!!!!!
大家有什么不明白的地方!QQ,,email 联系!
QQ47400789    
email [email protected]


 

本文地址:http://com.8s8s.com/it/it42002.htm