Visual Basic 6.0可以通過調用API函數格式化一個磁盤,無論是軟盤還是硬盤。
打開一個新的項目(工程1) ,如果你沒有更改過缺省模式,那么Visual Basic 6.0會自動添加一個form1文件,在form1上添加一個命令控件,將下面的代碼拷入。
Option Explicit
Private Declare Function SHFormatDrive Lib"shell32"( ByVal Hend AS Long,ByVal Drive AS Long,ByVal FormatID AS Long,ByVal Options AS Long) as Long
Private Sub FormatDisk(intDrive as integer,blnQuickFormat as Boolean)
Dim lngReturn As Long
if (blnQuickFormat) then
lngReturn= SHFormatDrive(0,intDrive,0&,1&)
else
lngReturn= SHFormatDrive(0,intDrive,0&,0&)
end if
end Sub
Private Sub Command1_Click()
call FormatDisk(0,True)
End Sub
運行此程序。
注意FormatDisk函數的第一個變量很重要,他的值是0,1,2時代表格式化的分別是:A、B、C盤。
利用WM5 實現電話功能
在程序中進行電話撥號
“項目”—“添加引用”—“Microsoft.WindowsMobile.Telephony”—“確定”
Imports Microsoft.WindowsMobile.Telephony
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TestPhone As New Phone
TestPhone.Talk("1001")
End Sub
其中:ClientInfor.inf 文件:
第一行的數據表示: 客戶端游戲版本號
第一行的數據表示: 更新文件存放的網絡路徑
UpdateInfor.inf文件:
第一行的數據表示: 最新游戲版本號
第二行的數據表示: 有多少文件需要更新
后面每行的數據表示: 需要更新的文件的名稱
frmUpdate.frm窗體: 負責下載
modZip.BAS模塊: 只負責用來壓縮文件和解壓縮文件的
其中的 UnZipTo 函數用來解壓縮的
zlib.dll: 為WinZip的dll文件
更新完畢后,ClientInfor.inf文件的第一行的數據會變為最新版本號
frmUpdate.frm窗體代碼如下:
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdUpdate_Click()
Dim strClientInfor() As String
Dim strUpdateInfor() As String
Dim nNum As Integer 存
MirUnleashed
vb.net
Module modMainServer
Public WithEvents Socket As New WinsockServer
Public WithEvents StatusSocket As New WinsockServer
Dim MonsterThread As New System.Threading.Thread(AddressOf MonsterProcess)
Dim LastPacket As String =
asp實現限制一個ip只能訪問一次的方法
<%
'/////////////////////////////////////////////////////
'// //
'//作用:一個IP地址只允許訪問本頁一次 //
'//引用:<!-- #include file="Check_Ip.asp" --> //
'// //
'/////////////////////////////////////////////////////
'Response.Charset = 936 '設置輸出編碼為簡體中文
'Response.Buffer = false '關閉緩沖區
Dim Fso,ts,IpList,Cfs
'設置Cookies函數
Function SetCookie()
Response.Cookies("IsBrow") = "Brow"
Response.Cookies("IsBrow").Expires = Date+365
End Function
'記錄IP地址函數
Function WriteIp(FileName, IpAddress)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Set ts = Fso.OpenTextFile(Server.MapPath(FileName),8,true)
ts.WriteLine IpAddress
ts.Close
Set ts = Nothing
Set Fso = Nothing
End Function
'讀取IP地址函數
Function ReadIpList(FileName)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
If Not Fso.FileExists(Server.MapPath(FileName)) Then
CreateFile("Iplist.txt")
Exit Function
End If
Set ts = Fso.OpenTextFile(Server.MapPath(FileName))
Iplist = ts.ReadAll
ts.Close
Set ts = Nothing
Set Fso = Nothing
ReadIpList = Iplist
End Function
'創建文件函數
Function CreateFile(FileName)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Set Cfs = Fso.CreateTextFile(Server.MapPath(FileName))
Cfs.Close
Set Cfs = Nothing
Set Fso = Nothing
End Function
'關閉當前IE窗口函數(注:IE6下通過,其他瀏覽器未測試)
Function CloseWindow()
'Response.Write "<script>window.location='javascript:window.opener=null;window.close();'</script>"
Response.Redirect "http://www.baidu.com"
End Function
Ip = Request.ServerVariables("REMOTE_ADDR") '獲取瀏覽者IP地址
Cookie = Request.Cookies("IsBrow") '獲取當前Cookies
'Response.Write Cookie
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") <> "" Then
Response.Write "本站不允許使用代理訪問"
Response.End()
Else
If Cookie = "Brow" Then
CloseWindow()
Else
If Instr(ReadIpList("Iplist.txt"),Ip) <>0 Then
CloseWindow()
Else
WriteIp "Iplist.txt" , Ip
End If
SetCookie()
End If
End If
%>