goback add

VB编写获得Windows目录的代码源码

4840 点击·0 回帖
灯火互联
楼主

之前写马的时候有用到,现在贴出来给大家看看,希望对大家有用,或者用的时候直接来圣剑之家找吧,呵呵。
模块:
Public 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 iValue     As String
  Private cValue     As String
    
  Public Function GetWinPath() As String
    
          cValue = Space(260)
          iValue = GetWindowsDirectory(cValue, Len(cValue))
          GetWinPath = Left(cValue, iValue)
    
End Function
Private Sub Form_Load()
MsgBox GetWinPath()
End Sub


调用就是GetWinPath() 嘿嘿, 够简单吧


喜欢0 评分0