shfileoperation delphi коды ошибок

Shfileoperation delphi коды ошибок

Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero.
It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Do not use GetLastError with the return values of this function.

To examine the nonzero values for troubleshooting purposes, they largely map to those defined in Winerror.h. However, several of its possible return values are based on pre-Win32 error codes, which in some cases overlap the later Winerror.h values without matching their meaning. Those particular values are detailed here, and for these specific values only these meanings should be accepted over the Winerror.h codes. However, these values are provided with these warnings:


http://www.podgoretsky.com15 ��� 09, 10:55����[7659293] �������� | ���������� �������� ����������

shfileoperation delphi коды ошибок. message. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-message. картинка shfileoperation delphi коды ошибок. картинка message. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.Re: ��� �������� ����� ���� ��� ������ �� SHFileOperation? [new]
aidynchik
Member

������:
���������: 553

Anatoly Podgoretsky
Return Value

Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero.
It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Do not use GetLastError with the return values of this function.

To examine the nonzero values for troubleshooting purposes, they largely map to those defined in Winerror.h. However, several of its possible return values are based on pre-Win32 error codes, which in some cases overlap the later Winerror.h values without matching their meaning. Those particular values are detailed here, and for these specific values only these meanings should be accepted over the Winerror.h codes. However, these values are provided with these warnings:

Источник

SHFileOperationA function (shellapi.h)

Copies, moves, renames, or deletes a file system object. This function has been replaced in WindowsВ Vista by IFileOperation.

Syntax

Parameters

A pointer to an SHFILEOPSTRUCT structure that contains information this function needs to carry out the specified operation. This parameter must contain a valid value that is not NULL. You are responsible for validating the value. If you do not validate it, you will experience unexpected results.

Return value

Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero.

It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Do not use GetLastError with the return values of this function.

To examine the nonzero values for troubleshooting purposes, they largely map to those defined in Winerror.h. However, several of its possible return values are based on pre-Win32 error codes, which in some cases overlap the later Winerror.h values without matching their meaning. Those particular values are detailed here, and for these specific values only these meanings should be accepted over the Winerror.h codes. However, these values are provided with these warnings:

Remarks

You should use fully qualified path names with this function. Using it with relative path names is not thread safe.

With two exceptions, you cannot use SHFileOperation to move special folders from a local drive to a remote computer by specifying a network path. The exceptions are the My Documents (CSIDL_PERSONAL, CSIDL_DOCUMENTS) and My Pictures folders (CSIDL_MYPICTURES).

When used to delete a file, SHFileOperation permanently deletes the file unless you set the FOF_ALLOWUNDO flag in the fFlags member of the SHFILEOPSTRUCT structure pointed to by lpFileOp. Setting that flag sends the file to the Recycle Bin. If you want to simply delete a file and guarantee that it is not placed in the Recycle Bin, use DeleteFile.

If a copy callback handler is exposed and registered, SHFileOperation calls it unless you set a flag such as FOF_NOCONFIRMATION in the fFlags member of the structure pointed to by lpFileOp. See ICopyHook::CopyCallback for details on implementing copy callback handlers.

File deletion is recursive unless you set the FOF_NORECURSION flag in lpFileOp.

Connecting Files

File connection is enabled by default. It can be disabled by adding a REG_DWORD entry, NoFileFolderConnection, as shown here:

Setting NoFileFolderConnection to 1 disables file connection. If the value is set to zero or is missing, file connection is enabled.

To move only the specified files and none of the connected files, set the FOF_NO_CONNECTED_ELEMENTS flag in the fFlags member of the structure pointed to by lpFileOp.

Note that the use of a folder with a name like «MyFile_files» to define a connection may not be valid for localized versions of Windows. The term «files» may need to be replaced by the equivalent word in the local language.

The shellapi.h header defines SHFileOperation as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Источник

Shfileoperation delphi коды ошибок

Профиль
Группа: Участник
Сообщений: 3
Регистрация: 24.8.2010

Репутация: нет
Всего: нет

Пишу программу на С++ с использованием Qt, необходимо удалять файлы в корзину под windows.
Использую для этого SHFileOperation, код приведен ниже.
Часть файлов удаляется нормально, вторая часть отказывается удалятся возвращая код «2».
Сижу в windows 7 (может быть это играет роль. ).

В msdn смотрел, не не нашел там такой ошибки в описании SHFileOperation, поиск в google выдаёт много мусора.

Что значит код ошибки 2 у SHFileOperation?
Может быть ошибка в написанном мною коде, если так, то покажите где.

Код
#include
#include

QString file_for_delete = str;
file_for_delete += «\0\0»;

SHFILEOPSTRUCT shfo=<0>;
shfo.wFunc=FO_DELETE;
shfo.pFrom = (wchar_t*)(file_for_delete.utf16());
shfo.fFlags =FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOERRORUI | FOF_ALLOWUNDO;
shfo.fAnyOperationsAborted=false;
shfo.hNameMappings=NULL;
shfo.pTo = NULL;
shfo.lpszProgressTitle=NULL;
int res = SHFileOperation (&shfo);
qDebug()

Код
Code: 2 File: «D:/Медиа/Аудио/Обезьянки, Вперед!_-_В каждом маленьком ребенке.mp3»
Code: 2 File: «D:/Медиа/Аудио/Новая папка/splin_-_vsego_horoshego.mp3»
Code: 2 File: «D:/Медиа/Аудио/Новая папка/yak_romantichno_pahn.mp3»
Code: 2 File: «D:/Медиа/Аудио/Новая папка/bob_marley_-_don_t_worry,_be_happy.mp3»
Code: 2 File: «D:/Медиа/Аудио/Новая папка/znp17ebay.mp3»
Code: 0 File: «D:/Медиа/Аудио/Новая папка/ME06M.rar»

Эксперт
shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Профиль
Группа: Завсегдатай
Сообщений: 5613
Регистрация: 21.8.2005
Где: Владимир

Репутация: 7
Всего: 118

Профиль
Группа: Участник
Сообщений: 3
Регистрация: 24.8.2010

Репутация: нет
Всего: нет

Цитата
Do not use GetLastError with the return values of this function.

Профиль
Группа: Участник
Сообщений: 19
Регистрация: 10.5.2010

Репутация: нет
Всего: нет

Цитата(Fealeron @ 24.8.2010, 20:59)
Нет, не смотрел. Потому, что прочитал вот что:

Ну так дочитайте до конца что ли:

Цитата
To examine the nonzero values for troubleshooting purposes, they largely map to those defined in Winerror.h. However, several of its possible return values are based on pre-Win32 error codes, which in some cases overlap the later Winerror.h values without matching their meaning.

Эксперт
shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.shfileoperation delphi коды ошибок. pip. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-pip. картинка shfileoperation delphi коды ошибок. картинка pip. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Профиль
Группа: Завсегдатай
Сообщений: 2243
Регистрация: 8.5.2006

Репутация: 39
Всего: 146

Код
#include
#include
#include

TCHAR *file_for_delete = new TCHAR[str.length()+2];
_tcscpy(file_for_delete, str.utf16());
file_for_delete[str.length()+1] = _T(‘\0’); // добавление второго нуля

SetFileAttributes(file_for_delete,FILE_ATTRIBUTE_ARCHIVE);
SHFILEOPSTRUCT shfo=<0>;
shfo.wFunc=FO_DELETE;
shfo.pFrom = file_for_delete;
shfo.fFlags =FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOERRORUI | FOF_ALLOWUNDO;
shfo.fAnyOperationsAborted=false;
shfo.hNameMappings=NULL;
shfo.pTo = NULL;
shfo.lpszProgressTitle=NULL;
int res = SHFileOperation (&shfo);
delete []file_for_delete;
qDebug()

Профиль
Группа: Участник
Сообщений: 3
Регистрация: 24.8.2010

Репутация: нет
Всего: нет

Код
#include
#include

QString file_for_delete = str;

file_for_delete.append(«69»); // добавляем в конец строки два символа, увеличивая её длину
file_for_delete[file_for_delete.size()-2] = 0; // заменяем два последних символа, которые только что добавили
file_for_delete[file_for_delete.size()-1] = 0; // на ‘\0’

SHFILEOPSTRUCT shfo=<0>;
shfo.wFunc=FO_DELETE;
shfo.pFrom = (wchar_t*)(file_for_delete.utf16());
shfo.fFlags =FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOERRORUI | FOF_ALLOWUNDO;
shfo.fAnyOperationsAborted=false;
shfo.hNameMappings=NULL;
shfo.pTo = NULL;
shfo.lpszProgressTitle=NULL;
int res = SHFileOperation (&shfo);
qDebug()

shfileoperation delphi коды ошибок. p pm on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p pm on. картинка shfileoperation delphi коды ошибок. картинка p pm on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p email on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p email on. картинка shfileoperation delphi коды ошибок. картинка p email on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p www on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p www on. картинка shfileoperation delphi коды ошибок. картинка p www on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p im on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p im on. картинка shfileoperation delphi коды ошибок. картинка p im on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p icq on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p icq on. картинка shfileoperation delphi коды ошибок. картинка p icq on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p aim on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p aim on. картинка shfileoperation delphi коды ошибок. картинка p aim on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p yim on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p yim on. картинка shfileoperation delphi коды ошибок. картинка p yim on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p msn on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p msn on. картинка shfileoperation delphi коды ошибок. картинка p msn on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p skype on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p skype on. картинка shfileoperation delphi коды ошибок. картинка p skype on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p gtalk on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p gtalk on. картинка shfileoperation delphi коды ошибок. картинка p gtalk on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p jabber on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p jabber on. картинка shfileoperation delphi коды ошибок. картинка p jabber on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p report on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p report on. картинка shfileoperation delphi коды ошибок. картинка p report on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p delete on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p delete on. картинка shfileoperation delphi коды ошибок. картинка p delete on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p edit on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p edit on. картинка shfileoperation delphi коды ошибок. картинка p edit on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p quick quote on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p quick quote on. картинка shfileoperation delphi коды ошибок. картинка p quick quote on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p quote on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p quote on. картинка shfileoperation delphi коды ошибок. картинка p quote on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p show on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p show on. картинка shfileoperation delphi коды ошибок. картинка p show on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p hide on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p hide on. картинка shfileoperation delphi коды ошибок. картинка p hide on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. shfileoperation delphi коды ошибок. p tofaq on. shfileoperation delphi коды ошибок фото. shfileoperation delphi коды ошибок-p tofaq on. картинка shfileoperation delphi коды ошибок. картинка p tofaq on. Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions.

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Chipset, Step, Fixin, GremlinProg, xvr. feodorv.

0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Системное программирование и WinAPI | Следующая тема »

[ Время генерации скрипта: 0.1403 ] [ Использовано запросов: 21 ] [ GZIP включён ]

Источник

Файловые операции средствами ShellAPI

Программер сидит дома, смотрит TV. За его спиной стоит комп. Из-за монитора выглядывает мальчик 5 лет:
— Пап, а пап, а фто знатит «формат драйв цэ камплит»?

В данной статье мы подробно рассмотрим применение функции SHFileOperation.

Данная функция позволяет производить копирование, перемещение, переименование и удаление (в том числе и в Recycle Bin) объектов файловой системы.

Функция возвращает 0, если операция выполнена успешно, и ненулевое значение в противном 🙂 случае.

Эта структура выглядит следующим образом:

Поля этой структуры имеют следующее назначение:

Если pFrom или pTo не указаны, берутся файлы из текущей директории. Текущую директорию можно установить с помощью функции SetCurrentDirectory и получить функцией GetCurrentDirectory.

Разумеется, вам нужно вставить в секцию uses модуль ShellAPI, в котором определена функция SHFileOperation.

Обратите внимание, что ни один из флагов не установлен. Если вы хотите не просто удалить файлы, а переместить их в корзину, должен быть установлен флаг FOF_ALLOWUNDO.

Выглядит ужасно, но работает. Можно написать красивее, просто лень.

И, наконец, функция, удаляющая файлы, переданные ей в списке Names. Параметр ToRecycle определяет, будут ли файлы перемещены в корзину или удалены. Функция возвращает 0, если операция выполнена успешно, и ненулевое значение, если руки у кого-то растут не из того места, и этот кто-то всунул функции имена несуществующих файлов.

Вроде все работает.

Файлы ‘Test1’ и ‘Test2’ удаляются совсем, без помещения в корзину, несмотря на установленный флаг FOF_ALLOWUNDO. Мораль: при использовании функции SHFileOperation используйте полные пути всегда, когда это возможно.

Ну, с удалением файлов разобрались.

Теперь очередь за копированием и перемещением.

Следующая функция перемещает файлы указанные в списке Src в директорию Dest. Параметр Move определяет, будут ли файлы перемещаться или копироваться. Параметр AutoRename указывает, переименовывать ли файлы в случае конфликта имен.

Все в порядке (а кудa ж оно денется).

Источник

10.9 Манипуляции с файлами и каталогами с помощью функции ShFileOperation стр.1

Delphi site: daily Delphi-news, documentation, articles, review, interview, computer humor.

Очень широкие возможности по копированию, перемещению, переименованию и удалению файлов и каталогов предоставляет функция API Windows ShFileOperation. В модуле ShellAPI она объявлена следующим образом:

FO_COPY Копирование файлов, указанных в поле pFrom, в файл или каталог, указанный полем рТо.

FO_DELETE Удаление файлов, указанных в поле pFrom. Поле рТо игнорируется.

Поле рЕгот указывает буфер, содержащий имя или имена файлов, с которыми производится заданная операция. Отдельные имена должны разделяться нулевыми символами. Завершаться список имен должен двумя нулевыми символами.

Поле рТо указывает буфер, содержащий имя файла или каталога, являющегося приемником. Если в поле 1Т1а£8 указан флаг ЕОЕ_МиЬ,ТГОЕ8ТЕ1Ь,Е8, то буфер может содержать список имен файлов. Отдельные имена должны разделяться нулевыми символами. Завершаться список имен должен двумя нулевыми символами.

Поле ГР1а£8 может содержать комбинацию следующих флагов:

Сохранить по возможности информацию для отмены операции. Например, при удалении файлов они перемещаются в корзину, из которой их потом можно восстановить.

Осуществлять операцию только при задании шаблона «*.*».

Отвечать «да для всех» на все вопросы, которые могут задавать диалоги в процессе выполнения операции: об удалении файлов, о создании новых папок и т.д.

Не делать запрос о создании нового каталога, если требуемый каталог отсутствует.

Не показывать окно с отображением хода процесса.

Показывать окно с отображением хода процесса, но не отображать в нем имена файлов.

Заполнить поле п№теМаррш£8. Указанный в нем дескриптор должен быть в дальнейшем освобожден функцией 8НРгее№теМаррш£8.

В поле fAnyOperationsAborted записи TSHFileOpStruct функция ShFileOpe-ration возвращает true, если выполнение операции было прервано пользователем. Поле hNameMappings содержит указатель на массив записей, содержащий прежние и новые полные имена всех файлов, над которыми проводились операции. Поле IpszProgressTitle содержит указатель текста, помещается в окно отображения процесса при включенном флаге FOF_SIMPLEPROGRESS.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *