最近在学习windows api在delphi中的应用,感觉这些api函数功能真够强大的,但deviceIoControl这个函数让我好是苦思,它在delphi winsdk中也没有说明不知道该如何使用,求救!!!!!
解决方案 »
- 想写一个自动答题的软件,大家帮忙看看,关于自动提交表单的问题.
- 对一个日期格式,如何获得日
- 动态窗体和自动窗体的小知识,望指教!
- 怎样根据一组数据在tchart中画出一条相应的正弦曲线??谢谢
- "Cannot perform this operation on a closed dataset"怎么回事?
- ascii转换(在线等)
- BlueTrees:接分!顺便问一下Delphi另两个问题!(关于MaskEdit)
- 开发CGI类型的WEB SERVICE,如何连接数据库啊?
- treeview和数据库联接问题
- 应该如何实现将DBGrid或StringGrid的显示内容的结果传送到Excel上呢
- 请教Delphi下如何枚举系统当前可用的串口
- 帮忙测试一下我的网站
To set a file's compression state, use the DeviceIoControl function with the
FSCTL_SET_COMPRESSION operation. Call the following function with the name of the file to compress and
boolean parameter 'forceCompress'. If that one is true, file will be compressed.
If it is false, the file will be compressed only if its parent folder is
compressed (reason for that parameter: if you MoveFile uncompressed file from
uncompressed folder to compressed folder, file will not become automatically
compressed - at least under some NT 4 service packs). Ein "compressed" Attribut kann man nicht mit der FileSetAttr Funktion setzen
sondern muss DeviceIoControl Funktion mit dem flag FSCTL_SET_COMPRESSION verwenden:
}
const
COMPRESSION_FORMAT_NONE = 0
COMPRESSION_FORMAT_LZNT1 = 2
COMPRESSION_FORMAT_DEFAULT = 1;
FILE_DEVICE_FILE_SYSTEM = 9;
METHOD_BUFFERED = 0;
FILE_READ_DATA = 1;
FILE_WRITE_DATA = 2;
FSCTL_SET_COMPRESSION = (FILE_DEVICE_FILE_SYSTEM shl 16) or
((FILE_READ_DATA or FILE_WRITE_DATA) shl 14) or (16 shl 2) or METHOD_BUFFERED;function SetCompressedAttribut(FileName: PChar; forceCompress: Boolean): Boolean;
var
hnd: Integer;
Comp: SHORT;
res: DWORD;
begin
if forceCompress or ((GetFileAttributes(PChar(ExtractFilePath(FileName))) and
FILE_ATTRIBUTE_COMPRESSED) <> 0) then
begin
Result := False;
if (GetFileAttributes(FileName) and FILE_ATTRIBUTE_COMPRESSED) = 0 then
begin
hnd := CreateFile(FileName, GENERIC_READ + GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
try
Comp := COMPRESSION_FORMAT_DEFAULT;
if not DeviceIoControl(hnd, FSCTL_SET_COMPRESSION, @Comp,
SizeOf(SHORT), nil, 0, res, nil) then Exit;
finally
CloseHandle(hnd);
end;
end;
Result := True;
end
else
Result := True;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
SetCompressedAttribut(PChar(OpenDialog1.FileName), True);
end;
end;