Добро пожаловать! Это — архивная версия форумов на «Хакер.Ru». Она работает в режиме read-only.
 

Help me with Visual C++

Пользователи, просматривающие топик: none

Зашли как: Guest
Все форумы >> [Веб-программинг] >> Help me with Visual C++
Имя
Сообщение << Старые топики   Новые топики >>
Help me with Visual C++ - 2005-01-09 18:40:38   
Anonymous

Сообщений: 4
Оценки: 0
Присоединился: 2005-01-09 18:24:23
Что нужно набрать, чтобы заставить консольную программу удалить, указанный в коде, файл???
Post #: 1
Help me with Visual C++ - 2005-01-09 19:42:11   
lirq

Сообщений: 142
Оценки: 0
Присоединился: 2004-06-07 16:15:39
смотри WinApi
Post #: 2
Help me with Visual C++ - 2005-01-10 08:22:27   
2Freak

Сообщений: 60
Оценки: 0
Присоединился: 2004-11-30 15:26:56
2 Anonymous:
function DeleteFile(lpFileName: PChar): BOOL;
но для удаления открытого файла под НТ юзай CloseHandle

а чем принципиально отличается код для КОНСОЛЬНОЙ программы? надеюсь, ты не под голый ДОС пишешь? там API совсем другой [sm=9.gif]
Post #: 3
Help me with Visual C++ - 2005-01-10 12:16:05   
alexei_II

Сообщений: 30
Оценки: 0
Присоединился: 2004-08-08 17:11:20
2Freak, тут по VCpp просят помочь, а не поДелфи [sm=1.gif]:
MSDN
The DeleteFile function deletes an existing file.


BOOL DeleteFile(
LPCTSTR lpFileName
);

Parameters
lpFileName
[in] Pointer to a null-terminated string that specifies the file to be deleted.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.

Windows Me/98/95: This string must not exceed MAX_PATH characters.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
If an application attempts to delete a file that does not exist, the DeleteFile function fails. If the file is a read-only file, the function fails with ERROR_ACCESS_DENIED. To delete a read-only file, you must first remove the read-only attribute.

To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory. If you set up a directory with all access except delete and delete child and the ACLs of new files are inherited, then you should be able to create a file without being able to delete it. However, you can then create a file get all the access you request on the handle returned to you at the time you create the file. If you requested delete permission at the time you created the file, you could delete or rename the file with that handle but not with any other. For more information, see File Security and Access Rights.

The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file.

Windows Me/98/95: The DeleteFile function deletes a file even if it is open for normal I/O or as a memory-mapped file. To prevent loss of data, close files before attempting to delete them.

To recursively delete the files in a directory, use the SHFileOperation function.

To close an open file, use the CloseHandle function.

The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to CreateFile to open the file fail with ERROR_ACCESS_DENIED.


Windows Me/98/95: DeleteFileW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

Example Code
For an example, see Creating and Opening Files.

Requirements
Client: Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Unicode: Implemented as Unicode and ANSI versions. Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Post #: 4
Help me with Visual C++ - 2005-01-10 12:42:40   
2Freak

Сообщений: 60
Оценки: 0
Присоединился: 2004-11-30 15:26:56
2 alexei_II:
[sm=mad.gif] бл, совсем запутался…
thnx за исправление [sm=1.gif]
Post #: 5
Страниц:  [1]
Все форумы >> [Веб-программинг] >> Help me with Visual C++







Связаться:
Вопросы по сайту / xakep@glc.ru

Предупреждение: использование полученных знаний в противозаконных целях преследуется по закону.