|
Thanks a lot, I was able to get it up and running.
|
|
|
|
|
hi,
I have a CDWordArray with many items. I need to sort it, in the quickest possible way.
Please tell me how to do it.
the code I use now is,
void CSortableDWordArray::Sort(DWORDCOMPAREFN pfnCompare)
{
DWORD * prgdw = GetData();
qsort(prgdw,GetSize(),sizeof(DWORD),(GENERICCOMPAREFN)pfnCompare);
}
It does not seem to be very fast.
regards
hari
Hari Krishnan
|
|
|
|
|
|
thanks,
About 10,000 to 20,000.
Another question, how about adding the items sorted while it is being added ? Which is faster.
Also, how can i use heapsort ?
regards
hari
Hari Krishnan
|
|
|
|
|
|
std::set from the STL does exactly this: hold a sorted collection of objects.
Depending on the access pattern you use with your collection, it may or may not be what you want.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
|
sequence 1:
MessageBox(NULL,"a test","a test",MB_OK);
BOOL b = PostThreadMessage(threadID,WM_TEST,0,0);
sequence 2:
BOOL b = PostThreadMessage(threadID,WM_TEST,0,0);
MessageBox(NULL,"a test","a test",MB_OK);
----------
The "sequence 1" and the "sequence 2" are identical except for sequence.The return value "b" proved that they sent the message "WM_TEST" successfully.But "sequence 2" didn't made the thread identified by "threadID" receiving the message.
Why???
For this, I should how to do???
Thank you in advance!
Rap off for you,for me,for our human.
|
|
|
|
|
Where is the WM_TEST message supposed to go ? Which thread does threadID designate ? Are you certain that this ID is correct ?
The message boxes are, by default, application modal. This means that the message pump handling of the application will pause for during the showing of the message box. In sequence 1, the results of posting the message WM_TEXT are visible only after you close the message box. In sequence 2, they MIGHT BE visible already during the showing of the box.
I say, might be, as PostThreadMessage returns before the message itself is handled. In sequence 2, the message is posted to the thread's queue, but if this thread is the same as which is to show the message box, then it might be that the message will not be handled before the message box is closed.
So, if threadID points to the same thread as which is to pop up the message box, then the thread's queue will be suspended until the closing of the box. You should never pop up modal message boxed in these type of situations. Use SendMessage to post a message to the thread's main window and wait for the window procedure to handle it. In this case, the application would either first show the message box, then handle the message, or vice versa.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi all,
Can anybody give me an example of Unicode programing. So I can change from current language to another (ex: Japanese to English) immediately.
Thanks all,
|
|
|
|
|
How can you send an email to like a hotmail account like someone@hotmail.com or any other web email???
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
|
I would like to send the email from my program.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
ahh
well you might want to try some of the SMTP classes found here on codeproject
or investigate MAPI
unless of course you want to connect your program directly to Hotmail
Bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
hi,
you need smtp class for send mail from ur program. u can refer http://www.naughter.com. very nice coding is there.
Have A Nice Day
Murali.M
|
|
|
|
|
thank you for the answer !
I used MAPI loosing some times, only to discover that it needs a mailing program already installed in my computer.
I hope that the smtp class do not require that, otherwise I cannot delete a single email on the server, for example, if I want to.
Do SMTP require that to ?
I also didn't find the code under http://www.naughter.com ( I didn't look thoughroughly into it though )
Thanks,
Marcello
|
|
|
|
|
I am trying to get process status information(cpu time, mem usage, etc) on all processes running on my Win XP system using C.
I have elevated the privilege of the current process to SE_DEBUG_NAME, but I get ERROR_ACCES_DENIED when I call OpenProcessToken() for the the following processes:
alg.exe
svchost.exe
svchost.exe
Task Manager reports that the user names for these processes are LOCAL SERVICE, LOCAL SERVICE, and NETWORK SERVICE respectively.
My goal is to extract the user sid from the process token so that I can display the user name like Task Manager does.
My program works for all other processes (except "idle").
1) What do I have to do to access the tokens for these processes?
It seems as if my current process is denied access to the process
token if the user name is either LOCAL SERVICE or NETWORK SERVICE.
2) How do I extract the same info for the idle process?
Thanks in advance
Daniel
|
|
|
|
|
Hello,
I am trying to add a cancel button to a modeless dialog I have created for my program. For this program, I enter information in the main dialog and when I click ‘Start’ a series of calculations are preformed. A second dialog box appears and acts as a status box – it sends information about the calculations to a text box in the second dialog. I have a cancel button on this second dialog that works, but only after EVERY calculation has been completed. My problem is this – I would like to have some way to check to see if the user has clicked the cancel button in between my calculation loop. Thanks in advance.
Loren
|
|
|
|
|
Hello,
You can add OnTimer() function in your main dialog. Include a code that will check say every 2 seconds if the modeless dialog is still open or not.
Example:
// say MyModeless is the modeless dialog object.
void CTFMHOSTView::OnTimer(UINT nIDEvent)
{
if(!MyModeless)
{ // means MyModeless has been closed
}
SetTimer(1,2000,0);// restart the timer again
CRecordView::OnTimer(nIDEvent);
}
rgrds,
Mar
Mar Solero Jr.
|
|
|
|
|
Spank me!! wrote:
My problem is this – I would like to have some way to check to see if the user has clicked the cancel button in between my calculation loop.
Either have the calculation done in a separate thread and stop this thread in your CANCEL-handler.
Or 'pump the message queue' in intervals while doing your calculation.
Call this function:
static bool PeekAndPump()
{
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return false;
}
}
LONG lIdle = 0;
while (AfxGetApp()->OnIdle(lIdle++));
return true;
}
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I have an MDI application whose main window icon is different than its document icons. As a result, whenever a document is opened in XP, the main window icon is replaced with a generic window icon in the taskbar. It would seem that this should be something easy to fix, but I haven't been able to find a solution. Thanks for the help.
Mike
|
|
|
|
|
I wrote a winsock service that spawns a new thread on the "accept" function. Sometimes it seems that when I "recv" the client doesn't seem to have closed the connection gracefully? The service continues to peg the CPU at 100% (even though I have checked for SOCKET_ERROR and byte size of 0 returned from "recv").
My question is.....(code is "pseudo-pseudocode")
Can I rely on the following to work properly considering the problems that I have found with closing the socket on the client end?
int nTimeout = 1000;
nError = setsockopt(client, SOL_SOCKET, SO_RCVTIMEO, (char*)&nTimeout, sizeof(nTimeout));
Or, is something like this going to be more reliable (albeit pretty ugly...), where the "accept" calls a timer thread which in turn calls the client thread until it times out(as follows)?
UINT ClientTimerThread(LPVOID pParam) {
CWinThread* thread;
LPDWORD exitvalue;
if (WaitForSingleObjectEx(thread = AfxBeginThread(ClientThread,pParam), 10000, false) == WAIT_TIMEOUT) {
socket s = (SOCKET)pParam;
closesocket(s);
GetExitCodeThread(thread, exitvalue);
TerminateThread(thread, (DWORD) exitvalue);
}
return 0;
}
Any advice would be greatly appreciated...
~LizardWiz()
|
|
|
|
|
Please do not even consider applying your second solution: TerminateThread is not to be used unless under catastrophic conditions.
In Winsock2 SO_RCVTIMEO works fine (you sure is Winsock2 and not 1.1 what you're using?) Nevertheless, even if it didn't work that wouldn't justify the CPU peak. Can you post more of the reading code?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I wrote mfc program to send email using SMPT protocols. The program works, but I noticed the followings:
1- My email is recognized as junk mail by major .com companies such as yahoo..
2-Microsoft hotmail won't deliver my email even though I got confirmation (code 250, 221), however, when I get code 250 I see message: "Queued mail for delivery". I do not know why the email is queued, anyway I never receive it.
Thanks for any clue.
|
|
|
|
|
It's hard to say, but the server probably parses the message and notices some important SMTP header is missing. You can try catching the output of a commercial mail application and mimicking that in your program, just for testing purposes: then, carefully erasing one header at a time you'll find what the server is requiring as mandatory. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|