//声明:GetWindowsDirectory(
lpBuffer: PChar;{缓冲区}uSize: UINT{缓冲区大小}): UINT;{返回实际长度}
//举例:vararr:array[0..MAX_PATH]ofChar;
num: UINT;beginnum := GetWindowsDirectory(arr, MAX_PATH);
ShowMessage(arr);{C:\WINDOWS}ShowMessage(IntToStr(num));{10}end;
//声明:GetSystemDirectory(
lpBuffer: PChar;{缓冲区}uSize: UINT{缓冲区大小}): UINT;{返回实际长度}
//举例:vararr:array[0..MAX_PATH]ofChar;
num: UINT;beginnum := GetSystemDirectory(arr, MAX_PATH);
ShowMessage(arr);{C:\WINDOWS\system32}ShowMessage(IntToStr(num));{19}end;
//声明:GetTempPath(
nBufferLength: DWORD;{缓冲区大小}lpBuffer: PChar{缓冲区}): DWORD;{返回实际长度}
//举例:vararr:array[0..MAX_PATH]ofChar;
num: DWORD;beginnum := GetTempPath(MAX_PATH, arr);
ShowMessage(arr);{C:\DOCUME~1\wy\LOCALS~1\Temp\}ShowMessage(IntToStr(num));{29}end;
//声明:GetTempFileName(
lpPathName: PChar;{路径}lpPrefixString: PChar;{前缀}uUnique: UINT;{指定生成文件名的数字, 文件名将根据参数2、参数3来生成}lpTempFileName: PChar{文件名需要的缓冲区}): UINT;{指定生成文件名的数字, 如果参数3是0, 则返回文件名长度}
//举例:varp,f:array[0..MAX_PATH]ofChar;beginGetTempPath(MAX_PATH, p);
GetTempFileName(p,'~My',16, f);{因为16的十六进制是10, 文件名会是: ~My10.tmp}ShowMessage(f);{C:\DOCUME~1\wy\LOCALS~1\Temp\~My10.tmp}end;
//声明:CopyFile(
lpExistingFileName: PChar;{源文件}lpNewFileName: PChar;{目标文件}bFailIfExists: BOOL{如果目标文件存在, True: 失败; False: 覆盖}): BOOL;
//例1:beginCopyFile('c:\BOOTLOG.TXT','c:\temp\BOOTLOG.TXT',True);end;
//例2:varExistFile, NewFile:string;beginExistFile :='c:\BOOTLOG.TXT';
NewFile :='c:\temp\BOOTLOG.TXT';ifCopyFile(PChar(ExistFile), PChar(NewFile),True)thenShowMessage('复制成功');end;
//声明:CreateDirectory(
lpPathName: PChar;{目录名}lpSecurityAttributes: PSecurityAttributes{TSecurityAttributes 结构的指针}): BOOL;//TSecurityAttributes 是 _SECURITY_ATTRIBUTES 结构的重定义_SECURITY_ATTRIBUTES =recordnLength: DWORD;{结构体的大小}lpSecurityDescrīptor: Pointer;{安全描述}bInheritHandle: BOOL;{安全描述的对象能否被新创建的进程继承}end;
//举例:vardir:string;begindir :='c:\temp\TestDir';
CreateDirectory(PChar(dir),nil);{第二个参数一般设为 nil, 表示使用系统默认的安全属性}end;
//声明:CreateDirectoryEx (
lpTemplateDirectory: PChar;{模版目录名}lpPathName: PChar;{新目录名}lpSecurityAttributes: PSecurityAttributes{TSecurityAttributes 结构的指针}): BOOL;//TSecurityAttributes 是 _SECURITY_ATTRIBUTES 结构的重定义_SECURITY_ATTRIBUTES =recordnLength: DWORD;{结构体的大小}lpSecurityDescrīptor: Pointer;{安全描述}bInheritHandle: BOOL;{安全描述的对象能否被新创建的进程继承}end;
//举例:varTDir,Dir:string;beginTDir :='c:\temp\Test';{假如模版目录是隐藏的}Dir :='c:\temp\NewDir';{创建的新目录也是隐藏的}CreateDirectoryEx(PChar(TDir), PChar(Dir),nil);{如果不需要模版, 可以:}//CreateDirectoryEx(nil, PChar(Dir), nil);end;
//声明:RemoveDirectory(
lpPathName: PAnsiChar{目录名}): BOOL;
//举例:varDir:string;beginDir :='c:\temp\Test';ifRemoveDirectory(PChar(Dir))thenShowMessage(Dir +' 已被删除')elseShowMessage('删除失败, 可能是 '+ Dir +' 不存在或不为空');end;
//声明:SetCurrentDirectory(
lpPathName: PAnsiChar{路径名}): BOOL;
GetCurrentDirectory(
nBufferLength: DWORD;{缓冲区大小}lpBuffer: PAnsiChar{缓冲区}): DWORD;{返回目录实际长度}
//举例:varbuf:array[0..MAX_PATH]ofChar;beginSetCurrentDirectory('c:\temp');
GetCurrentDirectory(SizeOf(buf), buf);
ShowMessage(buf);{c:\temp}end;
//声明:SetVolumeLabel(
lpRootPathName: PChar;{根路径}lpVolumeName: PChar{新卷标指针, nil 表示删除卷标}): BOOL;
//举例:beginSetVolumeLabel('c:\','NewLabel');end;
http://www.cnblogs.com/del/category/122469.html