VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Get the Windows and System directories.

Timothy Pew  (3 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

These two functions will return the location of the Windows directory (WinDir)
and the location of the System directory (SysDir).

Inputs
A boolean value indicating whether you would like a "\" character added to the end of the file path. Thus if you pass the value true it returns "C:\WINDOWS\" and if you pass false it returns "C:\WINDOWS".

Assumes
Put the API declarations and the functions in a standard module and you should be ready to go. The code is pretty easy to follow so I have no commented it. If you are having trouble understanding it and would like me to come back and add comments explaining it just leave a comment at the bottom of the page.

Returns
A string value containing the path of either the Windows directory or the System directory.

Side Effects
None that I know of. Leave a comment if you find one.

API Declarations
Public Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Rate Get the Windows and System directories. (2(2 Vote))
Get the Windows and System directories..bas

Get the Windows and System directories. Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters