Click here to Skip to main content
15,908,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListCtrl problem Pin
vcplusplus7-Oct-03 5:11
vcplusplus7-Oct-03 5:11 
QuestionA safe system place for confidental data? Pin
Osborn7-Oct-03 3:43
Osborn7-Oct-03 3:43 
AnswerRe: A safe system place for confidental data? Pin
David Crow7-Oct-03 4:17
David Crow7-Oct-03 4:17 
AnswerRe: A safe system place for confidental data? Pin
Terry O'Nolley7-Oct-03 4:23
Terry O'Nolley7-Oct-03 4:23 
GeneralRe: A safe system place for confidental data? Pin
Osborn7-Oct-03 7:36
Osborn7-Oct-03 7:36 
AnswerRe: A safe system place for confidental data? Pin
JWood7-Oct-03 9:13
JWood7-Oct-03 9:13 
GeneralWeb browser control Pin
Anthony98877-Oct-03 3:33
Anthony98877-Oct-03 3:33 
QuestionMoveFileEx not always working? Pin
Kayembi7-Oct-03 3:20
Kayembi7-Oct-03 3:20 
Hi,

I have an app that uses MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT. The app basically extracts some temporary files from a .zip file to a cache directory. After each file is extracted, a delete on reboot key is added to the registry if the system is WinNT/2000/XP, otherwise WinInit.ini is used. If the program ends normally, the registry keys are deleted (or WinInit.ini is restored to its former state). The idea is simply that the cached files are cleaned up no matter how the program ends.

However, there seems to be some bug whereby the files aren't always deleted on boot up. Strangely, sometimes they are, sometimes they aren't. I can't find any logic behind it, despite having tested it over and over again. In every case my code seems to be working fine, as I check the registry before rebooting and the PendingFileRenameOperations key contains all of the info that should be there (all the paths to the files I want to delete with \\?\ before them or whatever). When I reboot, the PendingFileRenameOperations key is gone - as though it has been executed - but the files are not always deleted. Very strange. This is the basics of the code I am using to do this:

<br />
/*<br />
Extract all files in a .zip archive and set them up so that they should be deleted<br />
on reboot if the PC is reset while the program is running:<br />
*/<br />
//fileno = number of files contained in a .zip file:<br />
for (int currfile = 0; currfile < fileno; currfile++)<br />
{<br />
	/*<br />
	Zip extraction is handled by the library available from www.artpol-software.com<br />
	*/<br />
	//Extract the file:<br />
	zip.ExtractFile(currfile,OutputPath_str);	//extract file from .zip by index to cache dir<br />
<br />
	//Set it up so that the file will be deleted if the PC is rebooted:<br />
	/*<br />
		EDITED: here I have some code that gets the file name<br />
		and file path from the current zip index number, and stores<br />
		the full path in a string, szCurrFile...<br />
		(I know this is working, because it displays the correct info in the registry)<br />
	*/<br />
<br />
	//For each file, remove it if PC is rebooted:<br />
	if(MoveFileEx(szCurrFile,NULL,MOVEFILE_DELAY_UNTIL_REBOOT)==0)<br />
	{<br />
		//Fall back to WinInit.ini...<br />
		//here I have my fallback code using WritePrivateProfileSection()<br />
	}<br />
<br />
	SetFileAttributes(szCurrFile,FILE_ATTRIBUTE_HIDDEN);<br />
<br />
	//Ensure window is updated if anything happens in the meantime:<br />
	if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))<br />
	{<br />
		if(msg.message == WM_QUIT) {<br />
			//If user destroys this program, skip to the end to clean up:<br />
			GRS_quit = 1;	//flag to tell rest of program to skip certain loops<br />
			break;<br />
		}<br />
		TranslateMessage(&msg);<br />
		DispatchMessage(&msg);<br />
	}<br />
}<br />


Like I say, if I reboot during this loop or immediately after it, although the correct info is in the registry, the files are not always deleted in restarting.

If anyone has any idea as to why I might be getting this peculiar problem, I would be really grateful.

Many thanks,
KB
AnswerRe: MoveFileEx not always working? Pin
David Crow7-Oct-03 3:55
David Crow7-Oct-03 3:55 
GeneralRe: MoveFileEx not always working? Pin
Kayembi7-Oct-03 6:02
Kayembi7-Oct-03 6:02 
GeneralRe: MoveFileEx not always working? Pin
David Crow7-Oct-03 6:15
David Crow7-Oct-03 6:15 
GeneralProgramm needs VC++ to run Pin
DarkMarine7-Oct-03 3:20
DarkMarine7-Oct-03 3:20 
GeneralRe: Programm needs VC++ to run Pin
vcplusplus7-Oct-03 3:48
vcplusplus7-Oct-03 3:48 
GeneralRe: Programm needs VC++ to run Pin
DarkMarine7-Oct-03 7:26
DarkMarine7-Oct-03 7:26 
GeneralRe: Programm needs VC++ to run Pin
vcplusplus7-Oct-03 7:55
vcplusplus7-Oct-03 7:55 
GeneralRe: Programm needs VC++ to run Pin
DarkMarine7-Oct-03 8:05
DarkMarine7-Oct-03 8:05 
GeneralRe: Programm needs VC++ to run Pin
vcplusplus7-Oct-03 9:29
vcplusplus7-Oct-03 9:29 
GeneralRe: Programm needs VC++ to run Pin
DarkMarine9-Oct-03 10:28
DarkMarine9-Oct-03 10:28 
GeneralRe: Programm needs VC++ to run Pin
Terry O'Nolley7-Oct-03 3:50
Terry O'Nolley7-Oct-03 3:50 
GeneralRe: Programm needs VC++ to run Pin
Stefan Pedersen7-Oct-03 3:51
Stefan Pedersen7-Oct-03 3:51 
Generalhelp with List box Pin
NewHSKid7-Oct-03 2:58
NewHSKid7-Oct-03 2:58 
GeneralRe: help with List box Pin
David Crow7-Oct-03 3:10
David Crow7-Oct-03 3:10 
GeneralRe: help with List box Pin
NewHSKid7-Oct-03 3:41
NewHSKid7-Oct-03 3:41 
GeneralRe: help with List box Pin
David Crow7-Oct-03 3:50
David Crow7-Oct-03 3:50 
GeneralRe: help with List box Pin
NewHSKid7-Oct-03 8:34
NewHSKid7-Oct-03 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.