|
namaskaaram wrote: I have a message handler thread which at some point need to flush out the message queue.
Call PeekMessage(...PM_REMOVE) in a loop until it returns 0.
But really, why? Where are the messages coming from and why
do you have no control over this?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Suppose the path comes as C:\Program Files\n1\n2,the code i am mentioning below only deletes the contents of n2 and n2.what modification should i do to delete n1 also.please reply immeaditely,as my project deadline is appraoching near.if posible reply to my e-mailid abhinay.krs@gmail.com
BOOL CMbaloadApp::DeletePath (CString& path)
{
HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
CString buffer;
BOOL bContinue = TRUE;
// Build enumeration of path contents
buffer = path;
NameAppendFile (buffer, "*.*");
// Init buffes
memset (&fd, 0, sizeof(fd));
// Perform find first...
hFile = FindFirstFile (buffer, &fd);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
// Check for directory attribute on
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// Directory Found!
// Make sure we don't have "." or ".."
if ( strcmp (fd.cFileName, ".") &&
strcmp (fd.cFileName, "..") )
{
// We have a valid directory, build path to it and
// call self to remove all
buffer = path;
NameAppendFile (buffer, fd.cFileName);
bContinue = DeletePath (buffer);
}
}
else
{
// Remove this file
buffer = path;
NameAppendFile (buffer, fd.cFileName);
// Normalize the file attributes prior to deleting it
SetFileAttributes(buffer, FILE_ATTRIBUTE_NORMAL);
TRY
{
// Get rid of it...
CFile::Remove (buffer);
}
CATCH( CFileException, e )
{
// Flag it, we can't remove directory
bContinue = FALSE;
DumpDebug ("Failed to delete file %s", buffer, 1);
}
END_CATCH
}
// Find the next entry...
} while (FindNextFile (hFile, &fd));
// Release file handle info
FindClose (hFile);
}
// Remove actual path itself
if (bContinue)
{
bContinue = (_rmdir(path) == 0);
}
return bContinue;
}
|
|
|
|
|
Abhinay Kumar wrote: what modification should i do to delete n1 also.
Recursion is one way. Another way is to use SHFileOperation() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi david.thanks for such a prompt reply.but Can u tell me how should i modify my code n where in case of recursion to delete n1?Or how and where
should i be using the other alternative u mentioned.if u can please reply
it's very imp. for me.thanks.
|
|
|
|
|
Abhinay Kumar wrote: should i be using the other alternative u mentioned.
You can, but that's ultimately up to you.
SHFILEOPSTRUCT shfo = {0};
shfo.wFunc = FO_DELETE;
shfo.pFrom = "C:\\Program Files\\n1\\*.*\0";
shfo.pTo = "\0";
SHFileOperation(&shfo);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi david i used the following recursive approach but it doesnot deletes
n1 in c:\program files\n1\n2.only deletes n2 and its contents.
if possible plz tell me what modification should i do to delete in n1 in this code or any other code to recursion.
BOOL CMbaloadApp::DeletePath (CString& path)
{
HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
CString buffer;
BOOL bContinue = TRUE;
// Build enumeration of path contents
buffer = path;
NameAppendFile (buffer, "*.*");
// Init buffes
memset (&fd, 0, sizeof(fd));
// Perform find first...
hFile = FindFirstFile (buffer, &fd);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
// Check for directory attribute on
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// Directory Found!
// Make sure we don't have "." or ".."
if ( strcmp (fd.cFileName, ".") &&
strcmp (fd.cFileName, "..") )
{
// We have a valid directory, build path to it and
// call self to remove all
buffer = path;
NameAppendFile (buffer, fd.cFileName);
bContinue = DeletePath (buffer);
}
}
else
{
// Remove this file
buffer = path;
NameAppendFile (buffer, fd.cFileName);
// Normalize the file attributes prior to deleting it
SetFileAttributes(buffer, FILE_ATTRIBUTE_NORMAL);
TRY
{
// Get rid of it...
CFile::Remove (buffer);
}
CATCH( CFileException, e )
{
// Flag it, we can't remove directory
bContinue = FALSE;
DumpDebug ("Failed to delete file %s", buffer, 1);
}
END_CATCH
}
// Find the next entry...
} while (FindNextFile (hFile, &fd));
// Release file handle info
FindClose (hFile);
}
// Remove actual path itself
if (bContinue)
{
bContinue = (_rmdir(path) == 0);
}
return bContinue;
}
|
|
|
|
|
Abhinay Kumar wrote: HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
Do you not like MFC's CFileFind class? Your code is much longer than it needs to be as a result.
Abhinay Kumar wrote: NameAppendFile (buffer, "*.*");
Why are you using this function when CString has its own concatenation method?
That said, have you stepped through this code using the debugger? You'll hopefully notice that the path parameter does not contain a valid path when called recursively (hint: it's missing a backslash).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all.
I have a created a DLL using c#...I have used structures to store some data..
Now i am calling DLL from vc++ win 32 Console application..
How i can use the structure...
Any idea
thank you
manju
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
manju#123 wrote: How i can use the structure...
Is it exported?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You can use an IntPtr in the C# code to hold the address of the structure. In the C++ code you can cast this pointer to a pointer to the structure.
If the structure is declared with the same members in both languages, it will probably be the same in memory.
|
|
|
|
|
I want to run my VC++ application in all types of users in windows XP and vista
How to achieve this.
|
|
|
|
|
|
hi I want to edit some system file while restart or shutdown
How to do that in VC++
|
|
|
|
|
pooja_friends wrote: How to do that in VC++
That's hard to say given the lack of information you've provided.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
pooja_friends wrote: edit some system file
do you have problem with this portion
pooja_friends wrote: restart or shutdown
or this one
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
In my application i have edited the system file for one reason.If i run my application in non-administrator user means application doesnt because of rights for editing that file.so i need do editing system while restarting the system.
|
|
|
|
|
ProcessShellCommand() call causes an unhandled exception in VS2005..
Anybody has solution plz reply..
THanks
|
|
|
|
|
Probably you don't initialize the parameters being sent to this function.
What happens when you debug ur code. Can you post some relevant code snippet.
it shouldn't be the function that would be causing a crash.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Check all needed and Zero all unneeded parameters.
Greetings from Germany
|
|
|
|
|
How are you verifying this? Have you called ParseCommandLine on the CCommandLineInfo first?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HI all ,
Well i definitely do a ParseCommandLine(cmdInfo);
and later if (!ProcessShellCommand(cmdInfo))
return FALSE;
cmdInfo members are as follows
m_nShellCommand = FileNew
m_bRunEmbedded = 0;
m_bRunAutomated = 0;
m_bShowSplash =1;
Rest all string members of cmdInfo are empty
Callstack at unhandled exception
msvcr80.dll!_crt_debugger_hook(int _Reserved=2015552886)
|
|
|
|
|
THis problem happens for my VS2003 code after i port it to VS2005
|
|
|
|
|
So how are you verifying that ProcessShellCommand() is the culprit?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i need to do a button click only once and after the button is clicked once i need to disable the buttonclick option untill the operations inside the button click get completed,what should be done???
|
|
|
|
|
I think it's same as your question, Disable the Button window (call CWnd::EnableWindow(FALSE)) in the button event handler and enable it (CWnd::EnableWindow(TRUE)) after done.
|
|
|
|