久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

VB入門技巧N例(9)

 zele 2011-01-31
27.清空回收站

  1. Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias _
  2. "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, _
  3. ByVal dwFlags As Long) As Long
  4. Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
  5. Private Const SHERB_NOCONFIRMATION = &H1
  6. Private Const SHERB_NOPROGRESSUI = &H2
  7. Private Const SHERB_NOSOUND = &H4
  8. Private Sub Command1_Click()
  9. Dim retval As Long  ' return value
  10.     retval = SHEmptyRecycleBin(RecycleBin.hwnd, "", SHERB_NOPROGRESSUI) ' 清空回收站, 確認(rèn)
  11.     ' 若有錯(cuò)誤出現(xiàn),則返回回收站圖示
  12.         If retval <> 0 Then  ' error
  13.         retval = SHUpdateRecycleBinIcon()
  14.     End If
  15. End Sub
  16. Private Sub Command2_Click()
  17.     Dim retval As Long  ' return value
  18.     ' 清空回收站, 不確認(rèn)
  19.     retval = SHEmptyRecycleBin(RecycleBin.hwnd, "", SHERB_NOCONFIRMATION)
  20.       ' 若有錯(cuò)誤出現(xiàn),,則返回回收站圖示
  21.     If retval <> 0 Then  ' error
  22.         retval = SHUpdateRecycleBinIcon()
  23.     End If
  24.     Command1_Click
  25. End Sub
復(fù)制代碼


28.獲得系統(tǒng)文件夾的路徑
  1. Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
  2. "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  3. Private Sub Command1_Click()
  4.    Dim syspath As String
  5.    Dim len5 As Long
  6.    syspath = String(255, 0)
  7.    len5 = GetSystemDirectory(syspath, 256)
  8.    syspath = Left(syspath, InStr(1, syspath, Chr(0)) - 1)
  9.    Debug.Print "System Path : "; syspath
  10. End Sub
復(fù)制代碼

29.動(dòng)態(tài)增加控件并響應(yīng)事件
  1. Option Explicit
  2.     '通過使用WithEvents關(guān)鍵字聲明一個(gè)對(duì)象變量為新的命令按鈕
  3.     Private WithEvents NewButton As CommandButton
  4. '增加控件
  5.     Private Sub Command1_Click()
  6.      If NewButton Is Nothing Then
  7.      '增加新的按鈕cmdNew
  8.      Set NewButton = Controls.Add("VB.CommandButton", "cmdNew", Me)
  9.      '確定新增按鈕cmdNew的位置
  10.       NewButton.Move Command1.Left + Command1.Width + 240, Command1.Top
  11.       NewButton.Caption = "新增的按鈕"
  12.       NewButton.Visible = True
  13.      End If
  14.     End Sub
  15.     '刪除控件(注:只能刪除動(dòng)態(tài)增加的控件)
  16.     Private Sub Command2_Click()
  17.      If NewButton Is Nothing Then
  18.       Else
  19.       Controls.Remove NewButton
  20.         Set NewButton = Nothing
  21.        End If
  22.     End Sub
  23.     '新增控件的單擊事件
  24.     Private Sub NewButton_Click()
  25.        MsgBox "您選中的是動(dòng)態(tài)增加的按鈕,!"
  26.     End Sub
復(fù)制代碼
  
30.得到磁盤序列號(hào)
  1. Function GetSerialNumber(strDrive As String) As Long
  2.   Dim SerialNum As Long
  3.   Dim Res As Long
  4.   Dim Temp1 As String
  5.   Dim Temp2 As String
  6.    Temp1 = String$(255, Chr$(0))
  7.    Temp2 = String$(255, Chr$(0))
  8.    Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, _
  9. Len(Temp2))
  10.    GetSerialNumber = SerialNum
  11. End Function
  12. 調(diào)用形式   Label1.Caption = GetSerialNumber("c:\")
復(fù)制代碼


31.打開屏幕保護(hù)
  1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd _
  2. As Long, ByVal wMsg As Long, ByVal wParam  

  3. As Long, lParam As Any) As Long
  4. '我們將要調(diào)用的那個(gè)消息,,在MSDN中搜索WM_SYSCOMMAND就可以找到具體說明
  5. Const WM_SYSCOMMAND = &H112
  6. '這個(gè)參數(shù)指明了我們讓系統(tǒng)啟動(dòng)屏幕保護(hù)
  7. Const SC_SCREENSAVE = &HF140&
  8. Private Sub Command1_Click()
  9. SendMessage Me.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0
  10. End Sub
復(fù)制代碼


32.獲得本機(jī)IP地址
方法一:利用Winsock控件
winsockip.localip
方法二:
  1. Private Const MAX_IP = 255
  2.     Private Type IPINFO
  3.      dwAddr As Long
  4.      dwIndex As Long
  5.      dwMask As Long
  6.      dwBCastAddr As Long
  7.      dwReasmSize As Long
  8.      unused1 As Integer
  9.      unused2 As Integer
  10.     End Type
  11.     Private Type MIB_IPADDRTABLE
  12.      dEntrys As Long
  13.      mIPInfo(MAX_IP) As IPINFO
  14.     End Type
  15.     Private Type IP_Array
  16.      mBuffer As MIB_IPADDRTABLE
  17.      BufferLen As Long
  18.     End Type
  19.     Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination _
  20. As Any, Source As Any, ByVal Length As  

  21. Long)
  22.     Private Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, _
  23. pdwSize As Long, ByVal Sort As Long) As Long
  24.     Dim strIP As String
  25.     Private Function ConvertAddressToString(longAddr As Long) As String
  26.      Dim myByte(3) As Byte
  27.      Dim Cnt As Long
  28.      CopyMemory myByte(0), longAddr, 4
  29.      For Cnt = 0 To 3
  30.      ConvertAddressToString = ConvertAddressToString + CStr(myByte(Cnt)) + "."
  31.      Next Cnt
  32.      ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
  33.     End Function
  34.       
  35.     Public Sub Start()
  36.      Dim Ret As Long, Tel As Long
  37.      Dim bBytes() As Byte
  38.      Dim Listing As MIB_IPADDRTABLE
  39.      On Error GoTo END1
  40.      GetIpAddrTable ByVal 0&, Ret, True
  41.      If Ret <= 0 Then Exit Sub
  42.      ReDim bBytes(0 To Ret - 1) As Byte
  43.      GetIpAddrTable bBytes(0), Ret, False

  44. CopyMemory Listing.dEntrys, bBytes(0), 4
  45.      strIP = "你機(jī)子上有 " & Listing.dEntrys & " 個(gè) IP 地址,。" & vbCrLf
  46.      strIP = strIP & "------------------------------------------------" & vbCrLf & vbCrLf
  47.      For Tel = 0 To Listing.dEntrys - 1
  48.      CopyMemory Listing.mIPInfo(Tel), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len _(Listing.mIPInfo(Tel))
  49.      strIP = strIP & "IP 地址 : " & ConvertAddressToString(Listing.mIPInfo(Tel).dwAddr)  & vbCrLf
  50.      Next
  51.      Exit Sub
  52. END1:
  53.      MsgBox "ERROR"
  54.     End Sub
  55. Private Sub Form_Load()
  56.      Start
  57.      MsgBox strIP
  58. End Sub
復(fù)制代碼

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多