這個是 當期 簡單文字版




 裡面還是靠webbrowser去寫的 


 只是為了方便抓 html元素


 如果用 httpwebrequest httpwebresponse 我還不知道怎麼把它丟進去 htmlelement 類別內

 

2011-09-18 20 37 43.png     

 

http://www.ziddu.com/download/16460523/taiwanlotto.rar.html

文章標籤

dark99 發表在 痞客邦 留言(0) 人氣()

先加入 參考 

Microsoft.mshtml.dll (或者 mshtml.tlb)

 

範例 :網頁原始碼大約如下

文章標籤

dark99 發表在 痞客邦 留言(0) 人氣()

下載點

    http://www.ziddu.com/download/14543606/Net_Open_Close.rar.html

 

 

Imports System.Runtime.InteropServices.GCHandle
Imports System.Runtime.InteropServices.GCHandleType


Public Class Form1


Private Const NetConnect As Integer = &H31
Private Function ExcNetLinkMenu(ByVal AdapterName As String, ByVal MenuName As String) As Boolean
On Error Resume Next
Dim Shell32 As Object
Dim lNameLenPtr As Integer
Dim lNameLen As Integer
Dim Handle As System.Runtime.InteropServices.GCHandle
Dim GCHandle As System.Runtime.InteropServices.GCHandleType
Handle = System.Runtime.InteropServices.GCHandle.Alloc("NetConnection", Pinned)
lNameLenPtr = Handle.AddrOfPinnedObject.ToInt32

Dim mShell As Shell32.Shell = New Shell32.Shell
Dim NetConnection As Shell32.Folder
Dim FolderItem As Shell32.FolderItem
Dim NetConnectionItem As New Shell32.ShellFolderItem
Dim verb As Shell32.FolderItemVerb
NetConnection = mShell.NameSpace(49)
If lNameLenPtr = 0 Then
ExcNetLinkMenu = False
GoTo exitfunction
End If
Dim flag As Boolean
flag = False
For Each FolderItem In NetConnection.Items
If FolderItem.Name = AdapterName Then
NetConnectionItem = FolderItem
flag = True
Exit For
End If
Next FolderItem
If flag = False Then
ExcNetLinkMenu = False
GoTo exitfunction
End If
For Each verb In NetConnectionItem.Verbs
If verb.Name = MenuName Then
flag = True
verb.DoIt()
ExcNetLinkMenu = True
GoTo exitfunction
End If
Next verb
If flag = False Then
ExcNetLinkMenu = False
GoTo exitfunction
End If
exitfunction:
mShell = Nothing
NetConnection = Nothing
FolderItem = Nothing
NetConnectionItem = Nothing
verb = Nothing
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  '把區域連線 6 換成你 網路名字
Dim blnRelust As Boolean
blnRelust = ExcNetLinkMenu("區域連線 6", "停用(&B)")
If blnRelust Then
MsgBox("停用成功")
Else
blnRelust = ExcNetLinkMenu("區域連線 6", "禁用(&B)")
End If
If blnRelust Then
MsgBox("停用成功")
Else
MsgBox("停用失败")
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim blnRelust As Boolean
blnRelust = ExcNetLinkMenu("區域連線 6", "啟用(&A)")
If blnRelust Then
MsgBox("启用成功")
Else
MsgBox("启用失败")
End If
End Sub
End Class


dark99 發表在 痞客邦 留言(0) 人氣()

利用 VB.net 取得本機 IP
Imports System.Net.Dns
 


Public Function GetIPaddress() As String
Try
Dim ipEntry As System.Net.IPHostEntry = GetHostByName(Environment.MachineName)
Dim IpAddr As System.Net.IPAddress() = ipEntry.AddressList
 


GetIPaddress = IpAddr(0).ToString
Catch ex As Exception
GetIPaddress = "無法取得IP"
End Try
End Function

dark99 發表在 痞客邦 留言(0) 人氣()

VB.net

'
' WebClient.DownloadFile
'
Dim wc As New WebClient()
wc.DownloadFile("http://www.google.com.tw", "c:/test.htm")

'
' WebClient.DownloadData
'
Dim wc As New WebClient()
Dim myDataBuffer As Byte() = wc.DownloadData("http://www.google.com.tw")
Dim sDownload As String = Encoding.GetEncoding("big5").GetString(myDataBuffer)
Console.Write(sDownload)

'
' WebRequest and WebResponse
'
Dim myHttpWebRequest As HttpWebRequest = DirectCast(WebRequest.Create("http://www.google.com.tw"), HttpWebRequest)
Dim myHttpWebResponse As HttpWebResponse = DirectCast(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()
Dim encode As Encoding = System.Text.Encoding.GetEncoding("big5")
Dim readStream As New StreamReader(receiveStream, encode)
Dim read As [Char]() = New [Char](255) {}
Dim count As Integer = readStream.Read(read, 0, 256)
While count > 0


Dim str As New [String](read, 0, count)


Console.Write(str)

count = readStream.Read(read, 0, 256)
End While
myHttpWebResponse.Close()
readStream.Close()


 ========================

C 語言

//
// WebClient.DownloadFile
//
WebClient wc = new WebClient();
wc.DownloadFile("http://www.google.com.tw", "c:/test.htm");

//
// WebClient.DownloadData
//
WebClient wc = new WebClient();
byte[] myDataBuffer = wc.DownloadData("http://www.google.com.tw");
string sDownload = Encoding.GetEncoding("big5").GetString(myDataBuffer);
Console.Write(sDownload);

//
// WebRequest and WebResponse
//
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.google.com.tw");
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("big5");
StreamReader readStream = new StreamReader( receiveStream, encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
while (count > 0) {
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
myHttpWebResponse.Close();
readStream.Close();

dark99 發表在 痞客邦 留言(0) 人氣()