schack8888
风云使者
风云使者
  • 注册日期2010-12-06
  • 发帖数686
  • QQ
  • 火币3641枚
  • 粉丝161
  • 关注102
阅读:3873回复:0

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

楼主#
更多 发布于:2011-07-20 12:49
之前写马的时候有用到,现在贴出来给大家看看,希望对大家有用,或者用的时候直接来圣剑之家找吧,呵呵。
模块:
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
兼职版主
游客

返回顶部