|
-
Oct 4th, 2000, 04:05 PM
#1
Thread Starter
Hyperactive Member
Does anyone know how to get the system directory
f.e. "C:\Windows\System", or "C:\WINNT\System32"?
I know how to get the temp directory:
Code:
Declare Function GetTempPath Lib "kernel32" Alias _
"GetTempPathA" (ByVal nBufferLength As Long, ByVal _
lpBuffer As String) As Long
Public Const MAX_PATH = 260
Function GetTempDir()
On Error Resume Next
Dim TempDir As String
TempDir = String(MAX_PATH, 0)
If GetTempPath(MAX_PATH, TempDir) <> 0 Then
GetTempDir = Left(TempDir, InStr(TempDir, _
Chr(0)) - 1)
Else
GetTempDir = ""
End If
End Function
Any suggestions?
thx, vbzero
-
Oct 4th, 2000, 04:08 PM
#2
_______
<?>
find the windows directory and system has to be under windows
Code:
'find the windows directory path
'usefull in shell commands if you know something
'is in the windows directory
'example..instead of shell c:\windows\notepad.ext
'you could use shell windir$ & /notepad.exe
'if windows was stored in E:/Windows then you wouldn't get an error
'if you used shell c:/windosw\notepad.exe, it couldn't be found '(error)
'
Option Explicit
Private Declare Function GetWindowsDirectory _
Lib "kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
'
Private Sub Form_Load()
'
Dim strFindWinDir$, WinDir$
'
WinDir$ = Space(144)
strFindWinDir$ = GetWindowsDirectory(WinDir$, 144)
WinDir$ = Trim(WinDir$)
'
MsgBox "The Windows Directory Path is: " & WinDir$
'
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 4th, 2000, 04:15 PM
#3
Thread Starter
Hyperactive Member
This won't work in Windows 2000/NT because the system
directory wouldn't be ..\System.
It would be ..\System32.
Primary in Windows 9x/Me the directories are C:\Windows\System and in 2000/NT C:\WINNT\System32.
The code which was posted only gets the windows directory
but not the system directory.
My program will work in Windows 9x and 2000/NT and so I need to find out the system directory in each system.
thx, vbzero
-
Oct 4th, 2000, 04:19 PM
#4
Fanatic Member
Code:
Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" (ByVal hwndOwner As Long, ByVal lpszPath As String, ByVal nFolder As Long, ByVal fCreate As Long) As Long
Const CSIDL_SYSTEM = &H25
Function GetSystemDir() As String
' Display the path of the directory used as the System
' special folder.
Dim pathname As String ' receives the path of System DDim retval As Long ' return value
' Make enough room in the buffer to receive the string.
pathname = Space(260)
' Get the path name of the My Documents special folder
retval = SHGetSpecialFolderPath(Form1.hWnd, pathname, CSIDL_SYSTEM, 0)
' Remove the empty space from the string.
pathname = Left(pathname, InStr(pathname, vbNullChar) - 1)
' Display the result.
GetSystemDir = pathname
This should do it
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 4th, 2000, 04:28 PM
#5
Thread Starter
Hyperactive Member
It works! Thanks!
thx, vbzero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|