|
Hi,
I want to get files list created,modified and last accessed on the basis of dates(i.e between 2 dates).How Can I do that.
Drushti
|
|
|
|
|
Use the CFileFind class to iterate through all the files in a specified folder (or subfolders, if you use recursion). From there you can get all the necessary file info for each file it iterates through.
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
bdiamond
|
|
|
|
|
Hi ,
I want to get the different File types with there Icons in the Combo box . How can I get it?
Drushti
|
|
|
|
|
Please explain furthur. I do not understand what you are asking.
John
|
|
|
|
|
Ok John,
Here are more details...
What I want is when I click the combo box down arrow,different types of file format ,for example:- Header file, source file,mp3 file, adobe acrobat file,Microsoft word file and so on (i.e all supported and recognized file format by OS), should be displayed.
To have a clear idea ...if u r using Windows 2000 professional , then click Search -> for Files or Folders ->Search Options (hyperlink)->Type->Combobox.
Hope Now I nust have cleared my point.
Drushti
|
|
|
|
|
me think you need to check the registry ( under HREF_CLASSES_ROOT ).
check the "OpenWithList" entries.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
MSDN indicates that windows creates a message queue along with each thread that is created. If I create a thread with CreateThread(), how do I gain access to the message queue?
The reason I ask, is that I would like a worker thread to use Winsock2 Async functions. Therefore can I use the thread's message queue to receive message based socket notifications.
Can anyone point me in the right direction?
Many thanks.
|
|
|
|
|
When you make a worker thread, it does not initially have a message queue. The first time you call a message queue-related API, a queue is created. To create a queue, use this:
MSG msg;
PeekMessage( &msg, (HWND) INVALID_HANDLE_VALUE, WM_NULL, WM_NULL, PM_NOREMOVE );
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Michael,
Many thanks. It all helps!
Spencer
|
|
|
|
|
MSDN indicates that windows creates a message queue along with each thread that is created
That's not exactly true. Threads only have a message queue if they call one of the thread processing functions, such as GetMessage, PeekMessage, or create a window.
Therefore can I use the thread's message queue to receive message based socket notifications
Yes, absolutely. It is easy to use a background thread to handle socket communication. But, before I give a brief description of how to handle Async sockets, I should mention there is a better method. Use event based sockets (WSAEventSelect instead of WSAAsyncSelect). The performance for event based is tremendously better than for async sockets. Message processing uses a lot of overhead. If your data load is small, then it won't matter too much which way you go, but if you expect high data streams, async sockets simply won't keep up.
Note: MFC's CAsyncSocket does not support event based, but it is not as hard to do it by hand as it may seem).
Now for async sockets:
Create your background thread. Inside your thread, create a non-visible window as a child of your main window. Use this background window to receive all socket notifications. In other words, pass this window handle to the AsyncSelect function.
If you're using MFC, create a CWinThread derived class. Use this class for the AfxCreateThread function. Inside the InitInstance function for this thread class, create your window and set it as the m_pMainWnd for the thread (just like what happens with CWinApp and CMainFrame). The built-in "Run" function will properly handle the message processing. Now just add an appropriate ON_MESSAGE handler to your background window class (just derive from CWnd).
|
|
|
|
|
Bill,
Many thanks for your helpfull reply. On examination of the WSAEventSelect, it looks like the better way to go.
However, I have some questions around the Thread and Window issue. Currently I'm not using CWinThread, I'm using the basic CreateThread windows function. If I was to create a new window, should I create it using the MFC CDialog::Create method or another way. Given the approach I'm currently using, I'm at a loss on how to add a message handler for the thread/ window.
Reading your text:
Bill Buklis wrote:
create your window and set it as the m_pMainWnd for the thread
Can I achieve this using my approach for creating the thread?
Any help would be much appreciated.
Spencer
|
|
|
|
|
If you go with WSAEventSelect, then no window or message queue is necessary and in fact is undesired. Also, if you're using MFC (sounds like you are), then you should not use the CreateThread function directly. It can confuse the runtime library and some thread specific states for MFC. Even without MFC there is a beginthread function for the runtime library.
Use AfxBeginThread (it will call the RTL's beginthread function for you). There are two versions of this function - one which uses CWinThread and one which simply calls a function like CreateThread.
|
|
|
|
|
I'm a bit of a newbie to the winsock stuff and mfc. When I compile the code with WSAEventSelect I get error C2065: 'WSAEventSelect' : undeclared identifier. I've tried including winsock2.h.
Any ideas?
Thanks in advance.
Spencer
|
|
|
|
|
Hi! I've encountered a new problem. Normally one declares an object of the form <class-name> <object> . But I had errors when i declared the object using the above format like syntax error , missing type specifiers or storage specifiers. When I declared using class <class-name> <object> the error simply vanished. What could be the reason??
Thanks in advance!!
Suman
|
|
|
|
|
I need to be able to start a Microsoft Access database (.mde) from my Visual C++ project. I have looked at several obvious ways like execl,spawn,createprocess and winexec. All these do not allow an application that is not a .exe application. If I used the system() function, it works fine. The only annoying thing is that it flashed the msdos screen. So does any body has any idea in how I can make this seamless.
Thanks,
Rhina
|
|
|
|
|
Rhina wrote:
I have looked at several obvious ways like execl,spawn,createprocess and winexec.
Actually, you missed the obvious choice: ShellExecute() . The others will work, but with a tad more effort.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
ShellExecute()is the one you want.
John
|
|
|
|
|
|
Hi,
I want to access the logical drives of a particular PC in LAN. How can I do that?
Drushti
|
|
|
|
|
By "logical" do you mean like C: and D:?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Then I concur with John's suggestion.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
What about UNC and administrative shares? Is this an option.
\\MachineName\c$
\\MachineName\d$
John
|
|
|
|
|
This about the 10th time I've posted this and still haven't gotten any definitive answer.
I have two classes, and one from CWinApp and one from CFrameWnd. All I want to do is print "abc" initialized in the constructor in random colored letters.
Could someone provide an moethod to accomplish this?
I alredy know GetAt() and CString str[i]... etc, but have been unsuccessful in getting the CString in anything but one color. I need an ALGORITHIM- thanks
|
|
|
|