1.

Solve : vb6 find system drive??

Answer»

hello!
need help in vb6. I starting to study vb6 and I want to know if what is the code in identifying the os drive? (like in  batch FILE, it uses %systemdrive%)
is there a substitute code for that in vb6?use the GetSystemDirectory Windows API function:

Code: [Select]Public Declare Function GetSystemDirectory_API Lib "kernel32" Alias "GetSystemDirectoryW" (ByVal Buffer As Long, ByVal BuffSize As Long) As Long
Public Function GetSystemDirectory() As String
    Dim usebuffer As String, nsize As Long
     'first retrieve LENGTH of required buffer..
    nsize = GetSystemDirectory_API(StrPtr(usebuffer), 0)
    usebuffer = String$(nsize, vbNullChar)
    GetSystemDirectory_API StrPtr(usebuffer), nsize
    GetSystemDirectory = Mid$(usebuffer, 1, INSTR(usebuffer, vbNullChar))
   
End Function

You can use Left$() to TAKE only the first CHARACTER to find the drive letter of the OS installation.



Discussion

No Comment Found