|
|
uhm, I already tried return FALSE, but it's not better.
.. I will try this a litter bit later.
Thank you very much, David Delaune.
|
|
|
|
|
does any one have any idea in this case???
help me, please!!!
|
|
|
|
|
maybe the best way is avoid it. It's terrible the way MFC handle an event,
anyway, thank you very much, Randor!!
|
|
|
|
|
how do i know the number of messages left unprocessed in a message queue?
|
|
|
|
|
This depends on the implementation of the message queue. If you have a message queue class, perhaps there is a getQueueLength() method? Or, if it's implemented similarly to a C string, perhaps there is a terminator at the end of an array? There is always a brute force approach, iterate through every element and count it, but this is not what I would call a good solution.
On that note, to give you a good answer, you need to post more information about what you're doing.
|
|
|
|
|
I am just reusing the message queue provided by windows. I have a message handler thread which at some point need to flush out the message queue. I didnt seem to find any win apis for the same.
|
|
|
|
|
I must admit, I havn't used the Microsoft queue, but I have used my own queues as well as queues written for POSIX in Linux. Typically, I've found that there is a length() method on the queue class. In the searches that I just ran I can't say that I've found this to be the case for Microsoft, but I did notice a few methods that could be used to cobble something up with from here: http://msdn.microsoft.com/en-us/library/ms699810(VS.85).aspx[^].
A few ideas that came to mind as I was reading this (unfortunately none of them are as elegant as a getLength() method). One idea that could work is to EnableNotification() and then to have your own counter that increments when a message is received and decrements when a message is used. Another is to use repeated calls to the PeekNext() method in a loop, counting the number of elements in the queue as you go.
Sorry I couldn't be more insightful for you. I hope that what I've found helps you set up an algorithm to get your program working the way you want it to.
|
|
|
|
|
Why would you think that Windows would need help in managing its message queue?
"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
|
|
|
|
|
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.
|
|
|
|