在PB中如何获取目录信息
⑴获取当前目录。通过GetCurrentDirectory函数可以获取当前目录,该函数声明为:
Function Ulong GetCurrentDirectoryA(Ulong buflen, ref String dir) Library ″kernel32.dll″
参数2为接收当前目录的字符缓冲区,前面必须加ref表示地址引用;参数1用来指定字符缓冲区的长度。调用过程为:
String curdir
curdir=Space(256)
//为字符缓冲区开辟内存空间
GetCurrentDirectoryA(256,curdir)
MessageBox(″Current Directory″,curdir)
⑵获取Windows及系统目录。要用到GetWindowsDirectory和GetSystemDirectory两个函数,须作如下声明:
Function Uint GetWindowsDirectoryA(ref String dir,Uint buflen) Library ″kernel32.dll″
Function Uint GetSystemDirectoryA(ref String dir,Uint buflen) Library ″kernel32.dll″