-
Windows folder
I have made a program that uses an ini-file. I want the ini-file to be placed in the Windows folder, but how do I know what folder the Windows folder is? I am workin under NT, so my Windows Folder is \WINNT\ , but people who re running 9x have the folder \WINDOWS\ . So how can my program know wich folder the Windows folder is?
-
Use the following API call:
Code:
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
private sub GetPath() as string
dim strRes as string
strRes = space(255)
strRes = left(strRes, getWindowsDirectory(strRes, len(strRes)))
GetPath = strRes
end sub
-
Code:
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Function GetWindowsFolder() As String
Dim Temp As String * 260
GetWindowsFolder = Left(Temp, GetWindowsDirectory(Temp, 260))
End Function
WinDir = GetWindowsFolder
Hope this helps,