|
- Can you give an example of a failing input string?
- You don't need these lines - the stringstream will be empty on cosntruction:
ss.clear();
ss.str(""); - Does using an ostringstream help (I doubt it)?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Problem solved using the .str() method, I finally could figure out a way to specialize my templates and use the unformated version with strings.
Anyway, thanks a lot for your valuable tips.
|
|
|
|
|
Hey, I'm doing sockets programming. Pretty much new to it.
The application is a Windows Service, in its ServiceMain() function I call CAsyncSocket's Listen() method, to listen for client connections. But after it starts listening for connections, it'll return and the ServiceMain() function will return and the service is stopped.
What I want to do with this is that, wait until a specific event occurs say WM_QUIT, till than listen for connections. How to do it?
void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
m_Server.StartListening();
}
I'm okay with mixing Win32 and MFC, so if it can be done in Win32 please do tell me too
|
|
|
|
|
Ahmed Manzoor wrote: What I want to do with this is that, wait until a specific event occurs say WM_QUIT
Does the service have a window (and associated window queue) on which to listen for window messages? Doubt it...
Instead, use a Win32 IPC event object[^] with a name specific to your service (hint: use an ASCII representation of a UUID to get a unique name) and wait on that with WaitForSingleObject[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But, won't that block the thread and everything will stop!
|
|
|
|
|
Quite true - I was thinking of the other sort of asynchronous IO that uses APCs (but that wouldn't work with WaitForSingleObject - it would need WaitForSingleObjectEx). OK. So, you need a window message pump to handle blocking for you...which is actually something that CSocket provides - whioch leads to the question - why not use CSocket instead of CAsyncSocket? I can't see any advantage to CAsyncSocket if you're only using one socket....
Anyway - to see how to block and process socket notifications, have a look at the CSocket message loop in CSocket::ProcessAuxQueue, which is in sockcore.cpp in your MFC source directory (that's C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc for me).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Okay, thanks I'll take a look at the source. Its not that I'm using only one socket . I'll add support for more connections, but later. I only need blocking for listening and everything else asynchronous.
I guess, I'll have to kick-off some threads. Any good strategy for using blocking listening and non-blocking I/O, MULTITHREADEDly
|
|
|
|
|
Hi,
I wanted to get the path of Recycle Bin in vista. But when i used
SHGetFolderPath with CSIDL_BITBUCKET , it returns E_FAIL.
how can i get the path of Recycle bin in Vista.
thanks
Nitheesh
Jose Jo Martin
http://www.simpletools.co.in
|
|
|
|
|
The Recycle Bin isn't a real folder - it's a virtual folder that aggregates the recycle bin folders from all drives that have them. Look at the documentation[^]:
CSIDL_BITBUCKET (FOLDERID_RecycleBinFolder)
The virtual folder that contains the objects in the user's Recycle Bin.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
While Stuart is correct that the Recycle Bin is considered a virtual folder... copies of the files and the INFO/INFO2 database are stored in multiple physical locations on mounted disk drive volumes.
Raymond Chen described a method for determining whether a folder is part of the recycle bin:
How can I tell that a directory is really a recycle bin?[^]
As far as I know..all folders with COM class identifier CLSID_RecycleBin have always been created in the root of the volume. So in theory you would need to enumerate all folders in the volume root directory and use Raymond's function to determine if they are part of the recycle bin.
Best Wishes,
-David Delaune
|
|
|
|
|
So...I guess the best response to the OP would have been 'why do you want to do that? Because if you tell us what you really want to do, we can probably give you a better answer...'.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This seems to be a recurring theme here on codeproject.com where a majority of the questions are poorly formed. When I determine that the author of the post does not know enough about the subject to properly form a question I try to include educational links and a brief summary in my comments to avoid future questions and elongated threads.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: This seems to be a recurring theme here on codeproject.com
Not just on CP - at work, I'm often asking people 'and your real question is???'
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi David,
Sorry for not describing what i am actually want to do. Here is my problem.
I am doing a project in which i wanted to show the user the files in Recycle bin so that they can make sure that no necessary files are getting deleted in a mistake from the file system. And i am programmatically clearing the Recylcle bin using the API SHEmptyRecycleBin(). So when the user click on button with Caption "Open Recycle Bin" i need to show them with the files in it.
thanks
Nitheesh.
Jose Jo Martin
http://www.simpletools.co.in
|
|
|
|
|
Nitheesh George wrote: when the user click on button with Caption "Open Recycle Bin" i need to show them with the files in it.
A codeproject search provided this example:
How to programmatically use the Recycle Bin[^]
Best Wishes,
-David Delaune
|
|
|
|
|
> Raymond Chen described a method for determining whether a folder is part of the recycle bin
Very bad "method".
(and avoid this poor blog (plenty of wrong notions, not professional at all..))
|
|
|
|
|
I know that sending WM_CLOSE or WM_DESTROY or WM_QUIT can destory a window created by other thread.
But this is not working when the target window is child window(With WS_CHILD Style, like property window in SDI).
[My Question is]
Can I destory other thread's child window?
If I can, please give me some advise about how to do it.
|
|
|
|
|
Did u open the thread with full access permission?
Величие не Бога может быть недооценена.
|
|
|
|
|
I am writing a text file . open it and write it any thing. Now I write a programme that open the file and read it . but I fail to read that data i write . As I save the data on text file by pressing save button and then read file by programme i am able to get data. why it is happenning ??. Is it neccessary to save the data before read . is there any method to read data from internal buffer of file that is not saved .
Trioum
|
|
|
|
|
trioum wrote: I am writing a text file . open it and write it any thing. Now I write a programme that open the file and read it . but I fail to read that data i write .
What do you mean exactly ? Do you open your text file with a program like notepad and then add some text to your file, without saving the file and then try to get back that data from the file directly ?
If you are wondering why this doesn't work, well, that's simply because you didn't save your file. The modifications are not commited to your file until you save it. In fact the modifications are kept in the "internal buffer" of notepad and there's no way to retrieve this information from the file directly.
trioum wrote: Is it neccessary to save the data before read
Yes
trioum wrote: is there any method to read data from internal buffer of file that is not saved .
No, because this data is kept in notepad, and not in the file.
|
|
|
|
|
Is there any way to retrieve that data from notepad
Trioum
|
|
|
|
|
But why do you want to do such a thing ? Why do you want to retrieve data which has not been saved to the file ?
Could you explain a bit what you are trying to achieve ?
|
|
|
|
|
yes reason for that .actually I have xml file which is updating continously by a third party software .
And I want to add its data into database . I open it as text file parse it data and add into the data base ,but problem is that it is not updated data that is in its buffer . it shows last updated data . and there is no way to save the xml file every milisecond .how can I solve my problem
Trioum
|
|
|
|
|
What does it have to do with notepad ? If your third party software updates the file directly, then there's nothing to do with notepad here.
Are you sure you read your data correctly ?
|
|
|
|
|
yes I read it correctly I open it as fopen("file.xml",rb);
Trioum
|
|
|
|