 |
 |

10-09-2004, 10:01 PM
|
|
Centurion
|
|
Join Date: Oct 2004
Posts: 176
|
|
Window directory ? How do i locate it
|
Hi, i would like to know how can i locate where the window(xp,nt,2000,me) is installed. =/
Thanks in advance
|
|

10-09-2004, 10:04 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
__________________
Quis custodiet ipsos custodues.
|

10-09-2004, 10:06 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2002
Location: Dubai & Srilanka (Jaffna)
Posts: 1,151
|
|
|
Use the GetWindowsDirectory API (For sample, please visit to AllApi.net)
Edit:
Oh... I am toooooooo Late
|
|

10-09-2004, 10:13 PM
|
|
Centurion
|
|
Join Date: Oct 2004
Posts: 176
|
|
|
o... but how come it return me a number instead of a path ?
|
|

10-09-2004, 10:33 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
|
You probably forgot to initialize the string buffer before calling the function.
|
__________________
Quis custodiet ipsos custodues.
|

10-09-2004, 10:35 PM
|
|
Centurion
|
|
Join Date: Oct 2004
Posts: 176
|
|
Quote:
|
Originally Posted by OnErr0r
You probably forgot to initialize the string buffer before calling the function.
|
could u give me an example on how u do it ?
|
|

10-09-2004, 10:40 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
Code:
Option Explicit
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const MAX_PATH = 260
Private Sub Form_Load()
Dim s As String
Dim lRet As Long
s = Space$(MAX_PATH)
lRet = GetWindowsDirectory(s, Len(s))
Debug.Print Left$(s, lRet)
End Sub
|
__________________
Quis custodiet ipsos custodues.
|

10-09-2004, 10:44 PM
|
|
Centurion
|
|
Join Date: Oct 2004
Posts: 176
|
|
|
oh cool i manage to get it working =D thanks !
|
|

10-09-2004, 11:22 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2002
Location: Dubai & Srilanka (Jaffna)
Posts: 1,151
|
|
Just I though...
No need to use the API for this, we can simply use the Environment variables to find the windows directory
Code:
'To get the Windows path
MsgBox Environ("windir")
'Or you can get this with the following variable
MsgBox Environ(41)
|
|

10-10-2004, 12:04 AM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
|
The Environ$ function with "windir" is a good bet. But don't hardcode to 41, that will often fail.
|
__________________
Quis custodiet ipsos custodues.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|