Re: Determining System Directories ??

From: Wes Spikes (MornThdr_at_NOSPAMverizon.net)
Date: 05/20/04


Date: Thu, 20 May 2004 23:42:15 GMT

I don't know of such in VB, but I do know of an API call that works for it!

Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long

You can use it like this:

Dim WinDir As String * 255
Dim gwdRet As Long

WinDir = Space(255)

gwdRet = GetWindowsDirectory(WinDir,Len(WinDir))

If gwdRet = 0 Then
 'there is an error using the API call that you must deal with, to get more
info
 ' you should be able to use GetLastError, but I'm not sure on what errors
 ' GetWindowsDirectory returns!
End If

WinDir = Trim(WinDir)

Hope this helps, and sorry to any potential repliers who might say that
something might be redundant, i'm improving this (except for the API
declaration, I'm not a genius <g>)!

-Wes

"JSE" <john@nospam.conwayinfo.ca> wrote in message
news:E7arc.517475$Pk3.173476@pd7tw1no...
> Hello everyone.
>
> Is there a function or variable available in Visual Basic that an
> application
> can read to determine the name of the current Windows directory. We want
> the application to be able to search for a file in the windows root
> directory, but
> what is its name? c:\winnt c:\windows c:\mysys it could be
anything.
>
> Is there a VB option for finding this?
>
> (something App.Path giving the current application directory).
>
> Thanks very much.
>
> John Edgar
>
>
>



Relevant Pages