Get Windows Directory

閲覧: 63 回
最初の未読メッセージにスキップ

Tom Shelton

未読、
2001/07/13 2:36:042001/07/13
To:
I have been searching the .NET framework docs for a way to get the path to
the windows directory. I saw in the Environment class the GetFolderPath
method, but the closest that gets me is C:/Windows/System - I only want the
C:/Windows. Yes, I can parse it out, but I was wondering if there was a way
to get C:/Windows only. Right now I have done this in my module:

Private Declare Ansi Function GetWindowsDirectoryA Lib "kernel32" _
(ByVal lpBuffer As String, ByVal uSize As Integer) As Integer

Private Function GetWindowsDirectory() As String
Dim sBuffer As String = New String(Convert.ToChar(0), 260)
Dim cChars As Integer = GetWindowsDirectoryA(sBuffer, 260)
Return sBuffer.SubString(0, cChars)
End Function

This works, but if there is a native way then I would like to know.

Thanks,
Tom Shelton


Bill McCarthy

未読、
2001/07/13 12:41:042001/07/13
To:
Hi Tom,

yes and no <g>

The System.Environment.GetFolderPath method will, but the Enum list of
special folders does not include Windows directory for some reason. however
yo ucan trick it into thinking it does, eg:

System.Environment.GetFolderPath(CType(&H24,
System.Environment.SpecialFolder))

"Tom Shelton" <t...@mtogden.com> wrote in message
news:#pJhic2CBHA.2200@tkmsftngp07...

Tom Shelton

未読、
2001/07/13 14:58:302001/07/13
To:
Thanks. I am trying my best to learn the frameworks. In my play I am trying to
not use the Microsoft.VisualBasic namespace. I am trying to do figure out what
can be done inside the framework and what can't. I appriciate the answer.

Tom Shelton

"Bill McCarthy" <bill...@iprimus.com.au> wrote in message
news:eLs4xr7CBHA.1448@tkmsftngp05...

Tom Shelton

未読、
2001/07/13 15:58:332001/07/13
To:
And it works too!

Tom Shelton

"Tom Shelton" <to...@dakcs.com> wrote in message
news:uUMqQ38CBHA.720@tkmsftngp05...

全員に返信
投稿者に返信
転送
新着メール 0 件