如何获得system32的路径?
如何用VB编写一个程序获得system32的路径
估计要用到API,但不太熟,请各位大侠帮帮忙
问题点数:20、回复次数:12Top
1 楼lxcc()回复于 2004-12-01 14:54:58 得分 5
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Command1_Click()
Dim sPath As String * 255
GetSystemDirectory sPath, 255
MsgBox sPath
End SubTop
2 楼tztz520(午夜逛街)回复于 2004-12-01 14:56:08 得分 4
Private Sub Form_Load()
MsgBox Environ("systemroot")
End SubTop
3 楼dongge2000(目前叫西西了)回复于 2004-12-01 14:58:13 得分 2
Option Explicit
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function WinDir() As String
Dim S As String
Dim Z As Long
Dim R As Long
S = Space(254)
Z = Len(S)
R = GetWindowsDirectory(S, Z)
WinDir = Left(S, R)
WinDir = WinDir & "\"
End Function
Public Function SysDir() As String
Dim S As String
Dim Z As Long
Dim R As Long
S = Space(254)
Z = Len(S)
R = GetSystemDirectory(S, Z)
SysDir = Left(S, R)
SysDir = SysDir & "\"
End Function
Public Function TempDir() As String
Dim S As String
Dim Z As Long
Dim R As Long
S = Space(254)
Z = Len(S)
R = GetTempPath(Z, S)
TempDir = Left(S, R)
End Function
Public Function UserName() As String
Dim S As String
Dim Z As Long
Dim R As Long
S = Space(254)
Z = Len(S)
R = GetUserName(S, Z)
UserName = S
End Function
Public Function ComputerName() As String
Dim S As String
Dim Z As Long
Dim R As Long
S = Space(254)
Z = Len(S)
R = GetComputerName(S, Z)
ComputerName = S
End Function
Top
4 楼HtoFire(冬天里的一把火)回复于 2004-12-01 17:06:39 得分 2
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Command1_Click()
Dim sTemp As String * 255
dim sPath as string
GetSystemDirectory sTemp , 255
sPath=left(instr(1,sTemp,chr$(0)-1)
End SubTop
5 楼frankwong(黄梓钿)回复于 2004-12-01 21:29:22 得分 3
Private Sub Form_Load()
MsgBox Environ("systemroot") & "\system32"
End Sub
Top
6 楼wumylove1234(毁于随)回复于 2004-12-02 09:42:13 得分 0
汗,这也行!
VB虽易,精者几何!
有道理.Top
7 楼Yh_King(永动机)回复于 2004-12-02 10:09:58 得分 0
VB是我心中的梦!
我只会VB+数据库,不只有没有发展前途?
yanghong1980924@tom.comTop
8 楼wumylove1234(毁于随)回复于 2004-12-02 10:39:31 得分 0
只会VB肯定不行的了.
精一个,熟N个.
数据库,Delphi,C++,C#,VB.Net.......Top
9 楼mingtian2008(明天)回复于 2004-12-02 10:58:57 得分 0
upTop
10 楼True1024()回复于 2004-12-02 13:47:51 得分 2
Option Explicit
Public Const MAX_PATH = 260
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Sub GetSystemDirectory_test()
Dim S As String, Length As Long
S = String(MAX_PATH, 0)
Length = GetSystemDirectory(S, MAX_PATH)
S = Left(S, InStr(S, Chr(0)) - 1)
MsgBox "Windows System 路径=" & S, , "GetSystemDirectory"
End Sub
Sub Main()
GetSystemDirectory_test
End SubTop
11 楼jackclh(艺海游鱼)回复于 2004-12-02 13:56:19 得分 0
支持dongge2000(秋日私语:非[版务].灌!) 所说!Top
12 楼fog(不会就问)回复于 2004-12-02 13:58:27 得分 2
Dim objCnFiles As Object
Set objCnFiles = CreateObject("Scripting.FileSystemObject")
MsgBox objCnFiles.GetSpecialFolder(1)
不知道是不是你要的Top




