Library tutorials & articles
Getting System Folders Easily via API
- Introduction
- Windoze Directory
- System Directory
- Temporary Directory
- Finally...
System Directory
The most important of all directories in my opinion is the System Directory.
Its vital that you dont simply use "C:\Windows\System32" or something
like that if you want to get your application to work in all platforms.
So heres another snippet for your enjoyment: Option Explicit
Private Declare Function GetSystemDirectoryB Lib "kernel32" Alias "GetSystemDirectoryA"
(ByVal Path As String, ByVal cbBytes As Long) As Long
Private Const MAX_LENGTH = 512
Public Function GetWindowsSystemDirectory() As String
Dim s As String
Dim c As Long
s = String$(MAX_LENGTH, 0)
c = GetSystemDirectoryB(s, MAX_LENGTH)
If c > 0 Then
If c > Len(s) Then
s = Space$(c + 1)
c = GetSystemDirectoryB(s, MAX_LENGTH)
End If
End If
GetWindowsSystemDirectory = IIf(c > 0, Left$(s, c), "")
End Function
So going back to our example used before, to read say the oohhhhh so important
EULA from Microsoft for your Windoze operating system: Dim iFileNum As Integer
Dim strEULA as string
iFileNum = FreeFile
Open GetWindowsSystemDirectory& "eula.txt" For Input As iFileNum
strEULA = Input$(LOF(iFileNum), iFileNum)
Close #iFileNum
msgbox strEULA, vbCritical, "UnImportant Aggreement"
Click 'Next>>' and dont collect the $100...
Related articles
Related discussion
-
Key_Press() event for text box
by Aquila (1 replies)
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
When you need the Temp folder, the easy (and clean .Net way) is to use: Path.GetTempPath()
it will still work for change dpaths... i used TweakXP to try it out on a few VMs and it worked fine... as far as other languaegs go... i only get English versions of OS's from MS so i dont know what the effects are, i suppose its teh same but i aint sure... amybe someone else maybe able to tell you.
so if the user changes their dir from say C:\WinNT\System32\ to C:\WindowsNT\System Files\ would i still be able to get the Windows DIR and System DIR?
also what about foreign languages?
hey,
sorry i couldnt reply earlier, I only saw my post now!
thank-you for your kind words!
Hey,
I must say this is EXTREEMLY useful for a nutcase like myself!
I infact had the exact problem you said most people have.
Thanks alot! It really helps!
This thread is for discussions of Getting System Folders Easily via API.