Here is some code i'm using to read the user's windows, system & temp directory... but i'm having some problems...
VB Code:
Option Explicit Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, _ ByVal nSize As Long) _ As Long Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _ ByVal nSize As Long) _ As Long Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, _ ByVal lpBuffer As String) _ As Long Private Const DIR_SYS As Byte = 0 Private Const DIR_WIN As Byte = 1 Private Const DIR_TEMP As Byte = 2 Private Function GetPath(ByVal PathType As Byte) As String GetPath = Space$(255) Select Case PathType Case DIR_SYS: Call GetSystemDirectory(GetPath, Len(GetPath)) Case DIR_WIN: Call GetWindowsDirectory(GetPath, Len(GetPath)) Case DIR_TEMP: Call GetTempPath(Len(GetPath), GetPath) End Select End Function Private Sub Command1_Click() MsgBox GetPath(DIR_WIN) MsgBox GetPath(DIR_SYS) MsgBox GetPath(DIR_TEMP) 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.




Reply With Quote