Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.08.22;
Скачать: CL | DM;

Вниз

Удаление файлов   Найти похожие ветки 

 
Anton777 ©   (2004-08-05 14:32) [0]

КАК удалить файлы при перезагрузке компьютера? Где можно написать список файлов которые будут удалены при перезагрузке компьютера?


 
RunOnce   (2004-08-05 14:35) [1]

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce


 
Anatoly Podgoretsky ©   (2004-08-05 14:39) [2]

В любом доступном месте.


 
Anton777 ©   (2004-08-05 14:40) [3]

И что туда просто моя программа должна закинуть список файлов(но это не так)Ведь нужен какойто параметр!Кстати RunOnce если память мне не изменяет отвечает за автозагрузку только единожды!


 
REA ©   (2004-08-05 14:48) [4]

Был какой-то скриптовый системный ini файл для стирания, копирования, замены файлов при перезагрузке. Не помню как называется.


 
RunOnce   (2004-08-05 14:49) [5]

Пишешь маленькую утилитку, которая и будет отвечать за удаление файлов и помещаешь её для одноразового старта в RunOnce, а для каждого рестарта в Run или в стартовое меню Автостарт.


 
Sergey Kaminski ©   (2004-08-05 14:56) [6]

Выдержка из MSDN.

Windows 95 and Windows NT each provide a unique method for helping applications to remove, replace, or rename files and directories that are in use. Although the two platforms differ in how they implement these methods, both share an overall strategy where the application specifies which files to process, and the system processes them when it reboots. This article explains how applications can use the method provided by each Windows platform.

MORE INFORMATION

Moving Files in Windows NT
Win32-based applications running on Windows NT should use MoveFileEx() with the MOVEFILE_DELAY_UNTIL_REBOOT flag to move, replace, or delete files and directories currently being used. The next time the system is rebooted, the Windows NT bootup program will move, replace, or delete the specified files and directories.

To move or replace a file or directory that is in use, an application must specify both a source and destination path on the same volume (for example, drive C:). If the destination path is an existing file, it will be overwritten. If the destination path is an existing directory, it will not be overwritten and both the source and destination paths will remain unchanged. Here is an example call to move or replace a file or move a directory:

 // Move szSrcFile to szDstFile next time system is rebooted
 MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
To delete a file or directory, the application must set the destination path to NULL. If the source path is a directory, it will be removed only if it is empty. Note that if you must use MoveFileEx() to remove files from a directory, you must reboot the computer before you can call MoveFileEx() to remove the directory. Here is an example of how to delete a file or empty a directory:

 // Delete szSrcFile next time system is rebooted
 MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
Moving Files in Windows 95
Windows 95 does not implement MoveFileEx(), but does provide an alternate way for all Win32-based, 16-bit Windows-based, and MS-DOS-based applications to move, replace, or delete files (but not directories) that are currently in use. This capability is implemented through the [rename] section of a file named Wininit.ini. If Wininit.ini is present in the Windows directory, Wininit.exe processes it when the system boots. Once Wininit.ini has been processed, Wininit.exe renames it to Wininit.bak.

The syntax of the [rename] section is:

DestinationFileName=SourceFileName
DestinationFileName and SourceFileName must reside on the same volume and be short (8.3) file names because Wininit.ini is processed before the protected mode disk system is loaded, and long file names are only available when the protected mode disk system is running. Destination and source files specified in Wininit.ini with long file names are ignored.

The [rename] section can have multiple lines with one file per line. To delete a file, specify NUL as the DestinationFileName. Here are some entry examples:

[rename]
NUL=C:\TEMP.TXT
C:\NEW_DIR\EXISTING.TXT=C:\EXISTING.TXT
C:\NEW_DIR\NEWNAME.TXT=C:\OLDNAME.TXT
C:\EXISTING.TXT=C:\TEMP\NEWFILE.TXT

Краткое резюме.

Под NT используем
 // Delete szSrcFile next time system is rebooted
 MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);

Под 95 используем файл winiinit.ini, секция [rename], синтаксис приведен


 
Ihor Osov'yak ©   (2004-08-05 15:17) [7]

для NT-ряда - см. функцию MoveFileEx с флагом MOVEFILE_DELAY_UNTIL_REBOOT
для рядя W9X - cм. wininit.ini, секция RENAME. Если нововое имя пустое - файл будет удален. Имена файлов должны быть короткие.
секция выглядит так:

[rename]
NewShortName=OldShortName

для случая удаления
[rename]
NULL=ShortFileNameForDelete
ps. 1. Для нт при использовании MoveFileEx + MOVEFILE_DELAY_UNTIL_REBOOT
имя файлов, подлежащих переименованию, сохраняются в ветке реестри
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations


 
Sergey Kaminski ©   (2004-08-05 15:20) [8]

Ihor Osov"yak ©   (05.08.04 15:17) [7]

Если нововое имя пустое - файл будет удален
Нет, не "пустое" а "NUL".


 
Ihor Osov'yak ©   (2004-08-05 15:21) [9]

2 [6] Sergey Kaminski ©

Сори, немного опоздал, отвлекли во время подготовки ответа.


 
Anton777 ©   (2004-08-05 15:24) [10]

Всем спасибо очень помагло!


 
Ihor Osov'yak ©   (2004-08-05 15:31) [11]

2 [8] Sergey Kaminski ©   (05.08.04 15:20)

см. пример :-). Но там также ошибка, все же NUL, а не NULL.

Да и нужно более четко использовать терминологию, Вы правы, это в части "имя пустое".


 
Sergey Kaminski ©   (2004-08-05 15:47) [12]

Ihor Osov"yak ©   (05.08.04 15:31) [11]

В моем примере (из MSDN) таки - "NUL"

:)


 
GuAV ©   (2004-08-05 16:04) [13]


> Был какой-то скриптовый системный ini

wininit.ini

[rename]
nul=c:\temp\killit.exe



Страницы: 1 вся ветка

Текущий архив: 2004.08.22;
Скачать: CL | DM;

Наверх




Память: 0.5 MB
Время: 0.046 c
1-1091601326
Nnn
2004-08-04 10:35
2004.08.22
Как в программе задать массив-константу?


1-1092138101
daiv
2004-08-10 15:41
2004.08.22
Добрый день. Есть список файлов


1-1092038078
bles
2004-08-09 11:54
2004.08.22
Проверить Edit1.Text - цифровой?


3-1090574765
}|{yk
2004-07-23 13:26
2004.08.22
Firebird и event


14-1091609155
Ricko
2004-08-04 12:45
2004.08.22
SMS голосование