|
|
发表于 2006-6-27 13:22:00
|
显示全部楼层
Re:一个代码看不懂,求教
这个程序代码写得很糟糕。
SysPath = Left(SysPath, GetSystemDirectory(SysPath, 145)) & "\"
虽然这一句实际运行没有什么问题,但是建议不要这样写,函数名不要随便乱用。
现在回来看代码
'这一个声明是一个取得系统路径的API
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function SysPath() As String
SysPath = String(145, Chr(0)) '这是将SysPath这个String型变量(注意此处SysPath是变量,不是函数名)赋值为145个chr(0)的字符,chr(0)就是获得ASCII码值为0的字符
SysPath = Left(SysPath, GetSystemDirectory(SysPath, 145)) & "\" '此句里面等号右边的所有SysPath都要按变量来理解,这也就是它糟糕的原因。
End Function
|
|