|
Look up CreateWaitableTimer()/SetWaitableTimer()
(I last used this about three years ago at a different company so I have no source; sorry.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If i create a thread to check if the time is up, is this the same with CreateWaitableTimer??
Thank you
|
|
|
|
|
Yes and no. You could do a timeout on a wait, but since the system clock can slip, the longer the timeout, the worse the precision. You're also limited to a relatively short period of time.
An alternative, which I have also used, is to have the thread wake up every hour, or some time period, check the time, then go back into the wait with a timeout (the wait was monitoring a shutdown event for graceful exit.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
If the thread wake up every hour, i set the clock between one hour scale.
Will i lose the chance to get the correct time??
I don't know why should go back into the wait with a timeout??
Thank for your help
|
|
|
|
|
Givens:
1) hEvent is a handle to an event
2) the following is in a thread
3) proper initialization has been done
for (;;)<br />
{<br />
if (WaitForSingleObject(hEvent, 60 * 60 * 1000) != WAIT_TIMEOUT)<br />
break;<br />
<br />
SYSTEMTIME time;<br />
GetSystemTime(&time);<br />
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
what's the difference when opening the file between in the way of text and
in the way of binary system?
|
|
|
|
|
One difference is how some characters are interpreted,
\r and \n for example.
Jens
|
|
|
|
|
Hello, Sir!
I am writing a MFC based program to extract files in a Zip archive, just like WinZip or WinRAR. I want to extract special files when I drop them from my CListView to the explorer or desktop. I think I must use delayed rendering to implement it.
I don't know how to do it. Could you give me some advice or example?
Thank you for your attention.
Best regards,
andy xia
andyxia@radinf.com
2004-05-04
|
|
|
|
|
What exactly is your problem?
Please give some more details.
Dow you just want to know how to
get the files that the user dropped
to the window of your application?
Jens
|
|
|
|
|
Hi,Jens,
Thanks for your reply.
In my program, I will do:
1. Drag some items from my ListView control to Windows Explorer.
2. I should get the target path where I finished the dragging.
3. If it is a valid path, I will extract the selected files to there.
My program is a Compress/Decompress tool just like WinZip and WinRAR.
In my ListView class, I responsed LVN_BEGINDRAG message to begin a dropping action like follow codes:
// Begin dropping...
CMyZipBoxDataSource datasrc;
FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
datasrc.DelayRenderFileData(CF_HDROP, &etc);
DROPEFFECT dwEffect = datasrc.DoDragDrop ( DROPEFFECT_COPY );
... ...
// End dropping
the Class CMyZipBoxDataSource is inherited from COleDataSource, and I overrided the function:
BOOL CMyZipBoxDataSource::OnRenderFileData(LPFORMATETC lpFormatEtc,CFile* pFile)
I don't know:
1. what should I write down in this function to handle this process?
2. how to get the target path the file will be extracted?
3. WinRAR extract selected files to a temp path after mouse up when draged. when it finished, move the extracted files to target path. Can I extract them to the target path directly?
That's my question, Thanks for your attention again.
Could you help me?
|
|
|
|
|
Sorry, I have not worked this way, till now I always accepted files to be dropped to my application, but yours is the other way round
But anyhow, your problem is much clearer now, maybe someone else can help you.
Sorry,
Jens
|
|
|
|
|
plz can any one help me in creating a dialog box with browse button to display path of the files in mfc i,e vc++
|
|
|
|
|
shiva shankar wrote:
plz can any one help me in creating a dialog box with browse button to display path of the files in mfc i,e vc++
LPMALLOC pMalloc;
/* Gets the Shell's default allocator */
if (::SHGetMalloc(&pMalloc) == NOERROR)
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
// Get help on BROWSEINFO struct - it's got all the bit settings.
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = _T("Select a Starting Directory");
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
// This next call issues the dialog box.
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
{
if (::SHGetPathFromIDList(pidl, pszBuffer))
{
// At this point pszBuffer contains the selected path */.
DoingSomethingUseful(pszBuffer);
}
// Free the PIDL allocated by SHBrowseForFolder.
pMalloc->Free(pidl);
}
// Release the shell's allocator.
pMalloc->Release();
}
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
when debugging a program,A messagebox pop up--"out of memory";and then the programe faile to do what it is expected to.what's the meaning of the message?
|
|
|
|
|
the meaning ??? -> you write out of the memory. clearly, you write in a memory address which is already allocated for another program an is not "for you".
track the lines where you write into an array for example...
TOXCCT >>> GEII power
|
|
|
|
|
I need an easy way to copy a file from my www-server to my CPU in my MFC-App
For e.g. from:
www.ceco.se/ExistingTxt.txt
To:
C:\ExistingTxt.txt
...and justice for all
APe
|
|
|
|
|
URLDownloadToFile(NULL, "www.ceco.se/ExistingTxt.txt", "C:\\ExistingTxt.txt", NULL, NULL);
or
use
CInternetSession,CHttpConnection ...
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
see internet api in SDK
Don't try it, just do it!
|
|
|
|
|
Can a nt service running under administrator account interact with desktop.
thanks in advance
|
|
|
|
|
Since services run before the user logs in, you will have to be carefull with what you do. The desktop may not be present when you expect it to be.
It is better to write an application that interfaces with the service and have a GUI less service IMO.
Ant.
|
|
|
|
|
Hi,
Just a quick question.
When writing an application. How do you handle error conditions?
In GDI+ e.g you are performing a series of operations each API call could go wrong.
Do you have a TRACE statement for *every* call you make?
What about Release mode?
Also you might make calls to many nested functions. Do you have an error for each nested call
or do you somehow pass the error up the chain?
How do nicely exit the program if you encounter a fatal error ? And No I dont think PostQuitMessage(0) is a good option.
Regards,
|
|
|
|
|
I have a project and if I rename a file I want to remove it from MRU if it is there,but I don't know how because there is only ID_FILE_MRU_FILE1 to 4.
Thanks.
|
|
|
|
|
Hi t o everyone reading this...
I have noticed that when an EditBox has the option singleline then if u add a notification handling function to it (lets say for the event EN_UPDATE ) and u call SetWindowText inside the function u instantly u receive a second notificatio and again and again.....
If though the EditBox has the option multiline the above behavior does not take place. Insted the notification arrives only once, SetWindowText sets the new text to the EditBox and the notification handling function exits.
Does anybody know why this deference exists? Does it serve a purpose?
In a single line EditBox how can i alter the text typed before it is displayed?
Thanks in advance for helping....
|
|
|
|
|
the winsock function recv and send seem can only send messages,can I use them to transferr a file? (I want to program a trojan backdoor)or I should use other method such as CSocket or ftp?Is there someone so kind to help me and give a detaied explaination?I can't find it in MSDN.
|
|
|
|
|
first of all, a file is just a stream of bytes. so to transfer the file, you need to read all the bytes of the file, and send them down your socket. Most likely, you'd read it in blocks and send the blocks down. eg 2048 bytes. On the other end, you need to be able to put that file back together. so you need to also send down the name of the file.
ftp is much easier. call the ftp process.
ftp -s:filename takes a file with ftp commands
|
|
|
|