Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Копирование папки [Win2k, WinXP]


Progh ©   (2004-12-17 10:25:00) 

Копирую папку ф-ией :

function CopyDir(const fromDir, toDir: string): Boolean;
var
 fos: TSHFileOpStruct;
begin
 ZeroMemory(@fos, SizeOf(fos));
 with fos do
 begin
   wFunc  := FO_COPY;
   fFlags := FOF_FILESONLY;
   pFrom  := PChar(fromDir + #0);
   pTo    := PChar(toDir)
 end;
 Result := (0 = ShFileOperation(fos));
end;

Все копируется отлично, но при копировании появляется стандартный Windows-овский диалог копирования, как мне убрать этот диалог копирования, чтобы все копирование происходило в фоновом режиме ?


DelphiN!   (2004-12-18 08:15:00) [1]

function CopyDir(const fromDir, toDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMemory(@fos, SizeOf(fos));
with fos do
begin
  wFunc  := FO_COPY;
  fFlags := FOF_NOCONFIRMATION or FOF_SILENT;
  pFrom  := PChar(fromDir + #0);
  pTo    := PChar(toDir)
end;
Result := (0 = ShFileOperation(fos));
end;


Anatoly Podgoretsky   (2004-12-17 19:45:00) [2]

Сильно ошибаешься, прочитай еще раз справку.


Fay   (2004-12-17 11:37:00) [3]

Напиши свою функцию - будет делать что захочешь


Progh   (2004-12-17 11:28:00) [4]


>  [6] Anatoly Podgoretsky ©   (17.12.04 11:26)
> А это по твоему что FOF_NOCONFIRMATION


Этот флаг указывает, чтобы не выводилось никаких сообщений, сообщения не выводятся, но и папка не заменяется, а мне нужно чтобы сообщение не выводилось, но и файлы заменялись новыми копиями ...


Anatoly Podgoretsky   (2004-12-17 11:26:00) [5]

А это по твоему что FOF_NOCONFIRMATION


Progh   (2004-12-17 11:12:00) [6]


>  [4] Fay ©   (17.12.04 11:08)


fflags:=fflags or FOF_SILENT or FOF_NOCONFIRMATION

Не спрашивает, и не заменяет ... А флага заменять нет ...


Fay   (2004-12-17 11:08:00) [7]

FOF_ALLOWUNDO  Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.  
FOF_CONFIRMMOUSE Not currently used.
FOF_FILESONLY  Perform the operation on files only if a wildcard file name (*.*) is specified.  
FOF_MULTIDESTFILES  The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.  
FOF_NOCONFIRMATION  Respond with "Yes to All" for any dialog box that is displayed.  
FOF_NOCONFIRMMKDIR  Do not confirm the creation of a new directory if the operation requires one to be created.  
FOF_NO_CONNECTED_ELEMENTS Version 5.0. Do not move connected files as a group. Only move the specified files.  
FOF_NOCOPYSECURITYATTRIBS Version 4.71. Do not copy the security attributes of the file.
FOF_NOERRORUI  Do not display a user interface if an error occurs.  
FOF_NORECURSION Only operate in the local directory. Don't operate recursively into subdirectories.
FOF_RECURSEREPARSE Recurse into reparse points. The default is to not recurse.  
FOF_NORECURSEREPARSE Treat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.  
FOF_RENAMEONCOLLISION  Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
FOF_SILENT  Do not display a progress dialog box.  
FOF_SIMPLEPROGRESS  Display a progress dialog box but do not show the file names.  
FOF_WANTMAPPINGHANDLE  If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
FOF_WANTNUKEWARNING Version 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION


Progh   (2004-12-17 11:06:00) [8]


>  [2] Fay ©   (17.12.04 10:54)
> FOF_SILENT ?


Спасибо, помогло, а можно ли еще убрать диалог с вопросом: Данный папка или файл уже существует, заменить или нет .. ?

Вобщем нужно чтобы он у пользователя не спрашивал заменить или нет, а просто сам заменял и все без вопросов ...


Fay   (2004-12-17 10:54:00) [9]

FOF_SILENT ?


Antoha   (2004-12-17 10:46:00) [10]

Ты вызываешь WinApi функцию, а конкретнее функцию шела или explorer'a. Дак вот если не хочешь чтобы окошко вылазило пиши свою функцию копирования каталога.


Наверх

Титульная страница Поиск, карта сайта Написать письмо