博文
VB获取硬盘个数(2008-04-30 14:20:00)
摘要:Private Sub Form_Load() Dim i As Integer On Local Error Resume Next Set wmiObjSet = GetObject( "winmgmts:{impersonationLevel=impersonate} ").InstancesOf( "Win32_DiskDrive ") For Each obj In wmiObjSet Debug.Print "标题 "; obj.Caption Debug.Print "描述: "; obj.Description Debug.Print "分区个数: "; obj.Partitions Debug.Print "容量: "; &nb......
ini文件的读写及小字名和关键字的删除技巧(2008-04-30 14:17:00)
摘要:一.ini文件的读写
Option ExplicitPrivate Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString As String, ByVal nSize As Long, ByVal lpFileName As String) As LongPrivate Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Long
Private r As LongPrivate entry As String
Function GetFromINI(AppName As String, KeyName As String, FileName As String) As String Dim RetStr As String RetStr = String(255, Chr(0)) GetFromINI = Left(RetStr, ......
VB自定义鼠标指针为手指样式(2008-04-30 14:14:00)
摘要:将label1的mousepointer属性值设置为99 ,mouseicon属性设置为小手图标,可以到c:\windows\cursors目录下找。......
VB文件操作代码集(2007-10-30 17:35:00)
摘要:1>VB编程:使用函数GetAttr()获取文件属性。
Private Sub Command1_Click() Print GetAttr("C:\Autoexec.Bat") If GetAttr("C:\Autoexec.Bat") And 1 Then Print "此文件只读" If GetAttr("C:\Autoexec.Bat") And 2 Then Print "此文件隐藏" If GetAttr("C:\Autoexec.Bat") And 4 Then Print "此文件为系统文件" If GetAttr("C:\Autoexec.Bat") And 16 Then Print "此文件为文件夹" If GetAttr("C:\Autoexec.Bat") And 32 Then Print "此文件为保存属性" End Sub
2>VB编程:使用 SetAttr函数设定文件的属性
例一:
Private Sub Command1_Click() SetAttr "C:\Autoexec.Bat", 1 + 2 + 32 Print "C:\Autoexec.Bat 此文件被设定成 只读 & 隐藏 & 保存属性" End Sub
例二:文件操作综合应用
Dim fs As New FileSystemObject '使用前必须首先选择[工程]→[引用],在出现的窗口中选择“microsoft scripting runtime”If MsgBox("是否安装?", 4 + vbExclamation, "安装") = vbYes Then On Error Resume Next If fs.FileExists("c:\menu.lst") Then '判断文件是否存在 SetAttr "c:\menu.lst", vbNormal '设置文件属性为正常 Kill "c:\menu.lst" '文件删除 End If SetAttr "c:\boot.ini", vbReadOnly + vbHidden +......
