VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)

VB爱好者乐园(VBGood)

 找回密码
 立即注册
搜索
楼主: 410023425

[分享] VB入门技巧N例

[复制链接]
 楼主| 发表于 2006-12-24 14:41:54 | 显示全部楼层
36.如何打开光驱
  1. Public Declare Function CDdoor Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString  

  2. As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  3. Call CDdoor("set CDAudio door open", 0, 0, 0)    '打开光驱
  4. Call CDdoor("set CDAudio door closed", 0, 0, 0)  '关闭光驱
复制代码
36.检测是否以联网及联网方式 module:
  1. Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
  2.     Alias "InternetGetConnectedStateExA" _
  3.     (ByRef lpdwFlags As Long, _
  4.     ByVal lpszConnectionName As String, _
  5.     ByVal dwNameLen As Long, _
  6.     ByVal dwReserved As Long _
  7.     ) As Long

  8. Public Enum EIGCInternetConnectionState
  9.     INTERNET_CONNECTION_MODEM = &H1&
  10.     INTERNET_CONNECTION_LAN = &H2&
  11.     INTERNET_CONNECTION_PROXY = &H4&
  12.     INTERNET_RAS_INSTALLED = &H10&
  13.     INTERNET_CONNECTION_OFFLINE = &H20&
  14.     INTERNET_CONNECTION_CONFIGURED = &H40&
  15. End Enum

  16. Public Property Get InternetConnected( _
  17.     Optional ByRef eConnectionInfo As EIGCInternetConnectionState, _
  18.     Optional ByRef sConnectionName As String _
  19.     ) As Boolean
  20.     Dim dwFlags As Long
  21.     Dim sNameBuf As String
  22.     Dim lR As Long
  23.     Dim iPos As Long
  24.      
  25.     sNameBuf = String$(513, 0)
  26.     lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0&)
  27.     eConnectionInfo = dwFlags
  28.     iPos = InStr(sNameBuf, vbNullChar)
  29.     If iPos > 0 Then
  30.         sConnectionName = Left$(sNameBuf, iPos - 1)

  31. ElseIf Not sNameBuf = String$(513, 0) Then
  32.         sConnectionName = sNameBuf
  33.     End If
  34.     InternetConnected = (lR = 1)
  35. End Property
  36. 窗体中
  37. Private Sub Form_Load()
  38.     ' Determine whether we have a connection:
  39.     bConnected = InternetConnected(eR, sName)

  40.     ' The connection state info parameter provides details
  41.     ' about how we connect:
  42.     If (eR And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then
  43.         sMsg = sMsg & "Connection uses a modem." & vbCrLf
  44.     End If
  45.     If (eR And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then
  46.         sMsg = sMsg & "Connection uses LAN." & vbCrLf
  47.     End If
  48.     If (eR And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then
  49.         sMsg = sMsg & "Connection is via Proxy." & vbCrLf
  50.     End If
  51.     If (eR And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then
  52.         sMsg = sMsg & "Connection is Off-line." & vbCrLf
  53.     End If
  54.     If (eR And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then
  55.         sMsg = sMsg & "Connection is Configured." & vbCrLf
  56.     Else
  57.         sMsg = sMsg & "Connection is Not Configured." & vbCrLf
  58.     End If
  59.     If (eR And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then
  60.         sMsg = sMsg & "System has RAS installed." & vbCrLf
  61.     End If
  62.    
  63.    ' Display the connection name and info:
  64.     If bConnected Then
  65.         Text1.Text = "Connected: " & sName & vbCrLf & vbCrLf & sMsg
  66.     Else
  67.         Text1.Text = "Not Connected: " & sName & vbCrLf & vbCrLf & sMsg
  68.     End If
  69. End Sub
复制代码


37.得到当前windows的版本号

module:
  1. Type OSVERSIONINFO
  2.         dwOSVersionInfoSize As Long
  3.         dwMajorVersion As Long
  4.         dwMinorVersion As Long
  5.         dwBuildNumber As Long
  6.         dwPlatformId As Long
  7.         szCSDVersion As String * 128      '  Maintenance string for PSS usage
  8. End Type
  9. Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  10. Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  11. Public Const SM_CLEANBOOT = 67
  12. Public Const SM_DEBUG = 22
  13. Public Const SM_SLOWMACHINE = 73
  14. Public Const VER_PLATFORM_WIN32s = 0
  15. Public Const VER_PLATFORM_WIN32_WINDOWS = 1
  16. Public Const VER_PLATFORM_WIN32_NT = 2
  17. 窗体中

  18. Private Sub Form_Load()
  19. Dim myVer As OSVERSIONINFO
  20. Dim nl As String
  21. Dim q As Long
  22. nl = Chr(10) & Chr(13)
  23. myVer.dwOSVersionInfoSize = 148
  24. q& = GetVersionEx(myVer)
  25. lblWininfo = ""
  26. lblMoreWininfo = ""
  27. If myVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then lblWininfo = lblWininfo & "运行平台 = Windows 95/98" & nl
  28. If myVer.dwPlatformId = VER_PLATFORM_WIN32_NT Then lblWininfo = lblWininfo & "Platform = Windows NT" & nl
  29. lblWininfo = lblWininfo & "Version = " & myVer.dwMajorVersion & "." & myVer.dwMinorVersion & " 创建于 " & (myVer.dwBuildNumber And &HFFFF&) & nl
  30. lblMoreWininfo = "Windows 现在运行在"
  31. If GetSystemMetrics(SM_CLEANBOOT) = 0 Then lblMoreWininfo = lblMoreWininfo & "正常模式" & nl
  32. If GetSystemMetrics(SM_CLEANBOOT) = 1 Then lblMoreWininfo = lblMoreWininfo & "安全模式" & nl
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-12-24 16:23:21 | 显示全部楼层
多谢楼主,存下来回去仔细研究下。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 09:19:00 | 显示全部楼层
呵呵  有点乱,凑合着看吧
回复 支持 反对

使用道具 举报

发表于 2006-12-25 11:26:23 | 显示全部楼层
这个不错,手工置顶一下

评分

参与人数 1威望 +2 收起 理由
Tsao4u + 2

查看全部评分

回复 支持 反对

使用道具 举报

发表于 2006-12-25 11:43:38 | 显示全部楼层
支持,很有用,谢谢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 11:48:46 | 显示全部楼层

回复 #14 ckz727 的帖子

有意思,心领了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 11:54:17 | 显示全部楼层

VB好多实例

收集的!分享一下

VB界面设计手册.RAR

215.22 KB, 下载次数: 922

回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 11:57:13 | 显示全部楼层

分享

这个好像是有人发过了

API函数详解.chm

364.41 KB, 下载次数: 711

回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 11:59:57 | 显示全部楼层

VB好多实例

..

VB实例.rar

421.94 KB, 下载次数: 832

回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-25 12:00:36 | 显示全部楼层

VB好多实例

....

VB实例2.rar

78.96 KB, 下载次数: 707

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

文字版|手机版|小黑屋|VBGood  

GMT+8, 2021-3-5 19:00

VB爱好者乐园(VBGood)
快速回复 返回顶部 返回列表