vb6。0中怎么使用简写的系统路径呢?
我该怎么使用%temp%
[解决办法]
用API
Declare Function GetWindowsDirectory Lib "kernel32 " Alias "GetWindowsDirectoryA " (ByVal lpBuffer As String, ByVal nSize As Long) As Long
获得系统目录
用
Declare Function GetUserName Lib "advapi32.dll " Alias "GetUserNameA " (ByVal lpBuffer As String, nSize As Long) As Long
取得用户名,然后进行字符串操作(写一个函数)
Private Function GetMyTempPath() As String
'C:\Documents and Settings\username\Local Settings\Temp
Dim mystring As String * 100
Dim myname As String * 100
Dim namelong As Long
Dim stringlong As Long
namelong = 100
stringlong = 100
GetWindowsDirectory mystring, stringlong
GetUserName myname, namelong
GetMyTempPath = Mid(mystring, 1, 1) & ":\Documents and Settings\ " & Mid(myname, 1, namelong - 1) & "\Local Settings\Temp "
End Function