An alternative to:
open "C:\Windows\System.ini" for input as #1
Input #1, strSomeString
Close #1
You can do this:
Open GetWindowsDirectory & "system.ini" for input as #1
Input #1, strSomeString
Close #1
So now when the users use it in say Windows NT 4 or Windows 2000(NT 5) you
wont get any errors to this critical windows required file.
The code to achieve this is quite easy. Insert the below code into a module(or
wait till the last section for all the code in one easy to use module).
Option Explicit
Private Declare Function GetWindowsDirectoryB Lib "kernel32" Alias "GetWindowsDirectoryA"
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const MAX_LENGTH = 512
Public Function GetWindowsDirectory() As String
Dim s As String
Dim c As Long
s = String$(MAX_LENGTH, 0)
c = GetWindowsDirectoryB(s, MAX_LENGTH)
If c > 0 Then
If c > Len(s) Then
s = Space$(c + 1)
c = GetWindowsDirectoryB(s, MAX_LENGTH)
End If
End If
GetWindowsDirectory = IIf(c > 0, Left$(s, c), "")
End Function
This will get the windows Directory via the 'GetWindowsDirectoryA
'
function in the Kernel32 API.
Press on...
Comments