Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
解决方案 »
- 为什么那些vb中不是标准控件的只要换台机子就得重新添加呢???
- 求助:怎么自动删除一条数据库中的记录
- 控件注册问题
- 请问如何在一个记录集中搜索除了一个特定记录外符合条件的记录啊?
- 问:ado对象连接中的资源释放
- 如何不通过设置BoarderStyle和ControlBox属性,禁止窗体缩放?
- 有关net share!!!!!!!
- 請問如何把vb編譯的程序轉成簡體系統語言
- VB ListView 中如何判断那些复选框是被选中的,那些不是?
- 高价收购hook resource和木马(太简单、太弱的就免了吧)源码学习参考.
- 在vb5中单击运行按钮后,出现“立即”窗口,程序不运行,有谁知道这是怎么回事?
- ????????????大虾们,请帮帮忙,谢谢!!!!!!!
Indx = 1 ' 设置索引值的初值为 1。
Do
EnvString = Environ(Indx) ' 取得环境变量。
If Left(EnvString, 5) = "PATH=" Then ' 检查 PATH 项。
PathLen = Len(Environ("PATH")) ' 取得长度。
Msg = "PATH entry = " & Indx & " and length = " & PathLen
Exit Do
Else
Indx = Indx + 1 ' 不是 PATH 项,
End If ' 则跳过此项,继续检查下一项。
Loop Until EnvString = ""
If PathLen > 0 Then
MsgBox Msg ' 显示消息。
Else
MsgBox "No PATH environment variable exists."
End If想找系统目录用windir(注意是小写)代替上面的PATH就行了
Dim a As String
Dim b As String * 256
a = GetSystemDirectory(b, 256)
则b内表示的就是系统目录
Dim spath As String
Dim a As Long
spath = Space(256)
a = GetSystemDirectory(spath, 256) 'a为返回系统路径长度
spath = Left(spath, a)
spath = spath & "\yb.ini"
Text1.Text = spath
End Sub