Results 1 to 3 of 3

Thread: Getting the users windows & system's dir... STILL UNRESOLVED

Threaded View

  1. #1

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718

    Getting the users windows & system's dir... STILL UNRESOLVED

    Here is some code i'm using to read the user's windows, system & temp directory... but i'm having some problems...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, _
    4.                                                                                         ByVal nSize As Long) _
    5.                                                                                         As Long
    6. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
    7.                                                                                           ByVal nSize As Long) _
    8.                                                                                           As Long
    9. Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, _
    10.                                                                           ByVal lpBuffer As String) _
    11.                                                                           As Long
    12.  
    13. Private Const DIR_SYS  As Byte = 0
    14. Private Const DIR_WIN  As Byte = 1
    15. Private Const DIR_TEMP As Byte = 2
    16.  
    17. Private Function GetPath(ByVal PathType As Byte) As String
    18.  
    19.     GetPath = Space$(255)
    20.  
    21.     Select Case PathType
    22.         Case DIR_SYS:  Call GetSystemDirectory(GetPath, Len(GetPath))
    23.         Case DIR_WIN:  Call GetWindowsDirectory(GetPath, Len(GetPath))
    24.         Case DIR_TEMP: Call GetTempPath(Len(GetPath), GetPath)
    25.     End Select
    26.  
    27. End Function
    28.  
    29. Private Sub Command1_Click()
    30.    
    31.     MsgBox GetPath(DIR_WIN)
    32.     MsgBox GetPath(DIR_SYS)
    33.     MsgBox GetPath(DIR_TEMP)
    34.    
    35. End Sub

    It displays the directories perfectly... but I can't input the findings into a string. IE... i have tried this...

    open DIR_WIN & "\test.txt" for append as #1

    & this...

    windowsdir = DIR_WIN
    windowsdir = getpath(DIR_WIN)

    but the string is then totally corrupt, and unusable.

    Any idea's peeps... i'm struggling like hell!

    Regards,

    Paul.
    Last edited by VisionIT; Feb 8th, 2003 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width