在线等 如何取得操作系统的安装目录即取得XP系统中的C:/windows,2000系统中的C:/winnt,要是安装在D盘则XP系统中的D:/windows,2000系统中的D:/winnt
解决方案 »
- vb 如何将数组里的数据逐行输出到文本框里
- vb如何像c一样,用&取地址?
- 传真组建faxcom的返回值的问题,在线等...
- datagrid如何更新到库啊
- 关于一个窗体显示在另一个窗体上的问题
- 如何将sum()求得的总数放在label上
- 选择报错,但运行还是有结果的?不知道何解?今天结分!
- 如何访问远程计算机?
- 请问怎样制作远程监视软件(互联网)?????????????????
- RECORDSET
- 如何取得操作系统的安装目录即取得XP系统中的C:/windows,2000系统中的C:/winnt,要是安装在D盘则XP系统中的D:/windows,2000系统中的D:/win
- 求一个VB自动计时程序!
private Property Get LocalSystemPath() As String
On Error Resume Next
LocalSystemPath = String$(256, Chr(0))
If GetSystemDirectoryA(LocalSystemPath, 256) <> 0 Then LocalSystemPath = Left$(LocalSystemPath & Chr(0), InStr(LocalSystemPath & Chr(0), Chr(0)) - 1)
Call Err.Clear
DoEvents
End Property
private Property Get LocalSystemPath() As String
On Error Resume Next
LocalSystemPath = String$(256, Chr(0))
If GetWindowsDirectoryA (LocalSystemPath, 256) <> 0 Then LocalSystemPath = Left$(LocalSystemPath & Chr(0), InStr(LocalSystemPath & Chr(0), Chr(0)) - 1)
Call Err.Clear
DoEvents
End Property
不知道怎么用啊?比如我单击Command1_Click() 让Label1.caption=取得的系统目录呢
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Function GetWinPath() '获取Windows目录
Dim strFolder As String
Dim lngResult As Long
strFolder = String(MAX_PATH, 0)
lngResult = GetWindowsDirectory(strFolder, MAX_PATH)
If lngResult <> 0 Then
GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
Else
GetWinPath = ""
End If
End FunctionPrivate sub command1_click()
label1.caption=GetWinPath()
end sub
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Command1_Click()
Dim b As String
Dim p As Integer
b = Space(260)
p = GetWindowsDirectory(b, Len(b))
WinPath = Left(b, p)
Text1.Text = WinPath
End Sub
Private Sub Command2_Click()
Dim b As String
Dim p As Integer
b = Space(260)
p = GetSystemDirectory(b, Len(b))
WinSysPath = Left(b, p)
text2.Text = WinSysPath
End Sub
Private Sub Command3_Click()
End
End Sub
注:请在窗体上加上两个文本框和三个按钮即可。