Finding Boot Drive

G

Gary Hillerson

Is there a function for finding the boot drive from within VBA that
will work will with Word '97 and later for Windows '98 or later?

I have an installer that installs an INI file in the Windows directory
on the user's system, which may or may not be on the C: drive. When my
template opens, I need to read that INI file, but I'm not sure how to
know the drive to use.

Thanks in advance,
gary
 
J

Jonathan West

Gary Hillerson said:
Is there a function for finding the boot drive from within VBA that
will work will with Word '97 and later for Windows '98 or later?

I have an installer that installs an INI file in the Windows directory
on the user's system, which may or may not be on the C: drive. When my
template opens, I need to read that INI file, but I'm not sure how to
know the drive to use.

Thanks in advance,


Place the following code into a separate module

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

Function WindowsFolder()
Dim strWin As String
strWin = Space(256)
GetWindowsDirectory strWin, Len(strWin)
WindowsFolder = Left$(strWin, InStr(strWin, Chr$(0)))
End Function

The WindowsFolder function returns the pathname of the windows folder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top