请问各位大哥,VB中如何得到windows路径

kevinmo 2005-10-13 09:47:10
如win98为c:\windows
win2000为c:\winnt
...全文
154 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jin0706 2005-10-13
  • 打赏
  • 举报
回复
个人认为获取环境变量最方便
threenewbee 2005-10-13
  • 打赏
  • 举报
回复
GetWindowsDirectory()
northwolves 2005-10-13
  • 打赏
  • 举报
回复
Private Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command1_Click()
Dim winpath As String
winpath = String(255, Chr(0))
GetWindowsDirectory winpath, 256 ' Read the path of the windows directory
winpath = Split(winpath, Chr(0))(0)
MsgBox winpath
End Sub
northwolves 2005-10-13
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
MsgBox Environ("WINDIR")
End Sub
laviewpbt 2005-10-13
  • 打赏
  • 举报
回复
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim sSave As String, Ret As Long
'Create a buffer
sSave = Space(255)
'Get the system directory
Ret = GetSystemDirectory(sSave, 255)
'Remove all unnecessary chr$(0)'s
sSave = Left$(sSave, Ret)
'Show the windows directory
MsgBox "Windows System directory: " + sSave
End Sub


7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧