标题: 如何用API函数控制获取Windows目录和System目录? [打印本页] 作者: 陈茜 时间: 2013-7-2 11:40 标题: 如何用API函数控制获取Windows目录和System目录? API函数作者: 淡写轻描 时间: 2013-7-2 11:44
注释:复制以下代码到一模块中Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPublic Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long注释:在程序中调用Dim WindowsDirectory As String, SystemDirectory As String, x As LongWindowsDirectory = Space(255)SystemDirectory = Space(255) x = GetWindowsDirectory(WindowsDirectory, 255)x = GetSystemDirectory(SystemDirectory, 255)MsgBox "Windows的安装目录是:" + WindowsDirectory+",系统目录是:" + SystemDirectory