首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb6。0中如何使用简写的系统路径呢

2012-01-16 
vb6。0中怎么使用简写的系统路径呢?我该怎么使用%temp%[解决办法]用APIDeclare Function GetWindowsDirecto

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

热点排行