如何得到当前Windows的安装路径?

wan_j_zhang 2001-07-20 03:42:03
...全文
90 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bdzwc 2001-07-21
  • 打赏
  • 举报
回复
api
kyuwong 2001-07-20
  • 打赏
  • 举报
回复
tg123 2001-07-20
  • 打赏
  • 举报
回复
Private Declare Function GetWindowsDirectory Lib "Kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Function GetWinPath()
Dim strFolder As String
Dim lngResult As Long

strFolder = String(260, 0)
lngResult = GetWindowsDirectory(strFolder, 260)
If lngResult <> 0 Then
GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
Else
GetWinPath = ""
End If
End Function
'GetWinPath()得知就是你要的东东
xxlroad 2001-07-20
  • 打赏
  • 举报
回复
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
Dim Path As String, strSave As String
strSave = String(200, Chr$(0))
Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
MsgBox Path
End Sub
acqy 2001-07-20
  • 打赏
  • 举报
回复
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" ( ByVal lpBuffer as String, ByVal nSize As Long)
以上函数得到的是Windows系统目录(SYSTEM)的完整路径,有了它,相信得到WINDOWS的完整路径就不困难了。
xxlroad 2001-07-20
  • 打赏
  • 举报
回复
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
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

xxlroad 2001-07-20
  • 打赏
  • 举报
回复
GetWindowsDirectory
zhhrlzm 2001-07-20
  • 打赏
  • 举报
回复
app.Path

7,762

社区成员

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

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