|
This is more about Power Management than Disk Management.
So (assuming that the disk doesn't have inbuilt smartness to act on power management and completely relies on OS for power mgt),
1. You could set the power management policy in windows (Control Panel!!!) so that it doesn't put the HD in sleep. This doesn't require coding but than needs human intervention in every PC where you run your app.
2. Play with power management API ( SetSystemPowerState(..) or alike) so that your app can notify the OS to not step in and do power management. Don't forget to revert system state on application exit (if required).
But must say, above are from my concept rather than any real work relating to such situation. But I know for sure that there exists some API where a app can tell OS to not kick in power mgnt policy.
|
|
|
|
|
Hi all, im having trouble with the following code:
<br />
void read(void){<br />
const int buffer4=900;<br />
char buffer[BUFSIZ]={'\0'};<br />
char sysfolder4[buffer4];<br />
ifstream file;<br />
ExpandEnvironmentStrings("%systemroot%\\file.txt", sysfolder4, buffer4);<br />
file.open(sysfolder4, ios::in);<br />
if(file.fail()){<br />
msg = "PRIVMSG " + chan1 + " file is not detected..\n";<br />
SendToServer(msg.c_str());<br />
}<br />
else{<br />
msg = "PRIVMSG " + chan1 + " Listing file..\n";<br />
SendToServer(msg.c_str());<br />
while(file.getline(buffer, BUFSIZ)){<br />
Sleep(500);<br />
msg = "\r\nPRIVMSG " + chan1 + " :" + buffer;
SendToServer(msg.c_str());<br />
}<br />
file.close();<br />
msg = "\nPRIVMSG " + chan1 + " :End of file.";<br />
SendToServer(msg.c_str());<br />
}<br />
}<br />
Its suppose to read a file, and close when its done reading the file. However it reads the file, and finishes at the very last line, but stops until another command is entered and prints something un-wanted.
Here's what i'd like to happen.
<quote>
[master] list sample
[ client ] sample random text file.
[ client ] test file reading.
[ client ] read.
[ client ] End of file.
And here's what happens instead.
<quote>
[master] list sample
[ client ] sample random text file.
[ client ] test file reading.
[ client ] read.
[ master ] test
[ client ] End of file.PRIVMSG #chan :This is only a test
Can anyone tell me what could be wrong?? I've tried escape characters but they dont seem to do much, what could be wrong with the string buffer? Any help would be appreciated, thanx in advance!
|
|
|
|
|
in side the while loop put an if statement to break the loop.
the if statement should come before sending to server. in your case before Sleep
like
if( eof() )
{
break;
}
Regards
Anil
|
|
|
|
|
Hi there,
I has a variable that needs to be accessed by multiple threads. To avoid multiple accesses by different threads at the same time, I want to use EnterCriticalSection to enable the exclusive access. However, MSDN instructs that "The process is responsible for allocating the memory used by a critical section object, which it can do by declaring a variable of type CRITICAL_SECTION." I wonder how I should declare a critical section object.
Thanks a lot,
zipliu
|
|
|
|
|
I mean, for example, I want to make a integer to be a critial section object. Thanks.
|
|
|
|
|
zipliu wrote: I wonder how I should declare a critical section object.
CRITICAL_SECTION cs;
EnterCriticalSection(&cs);
...
LeaveCriticalSection(&cs);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To add to DavidCrow's reply...
You can put the CRITICAL_SECTION object anywhere it's accessible by ALL threads that need it.
All threads that need to synchronize need to use the same CRITICAL_SECTION object.
Also, InitializeCriticalSection() (or InitializeCriticalSectionAndSpinCount()) should be called
by one of your threads before using the critical section.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What is the significance of using Variants data type. Is it sufficient that they only have a union of various data types and that they can be used by dispatch clients.
|
|
|
|
|
Here is a brief explanation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How does the frame gets destroyed in MFC? Why is the frame window created on the heap as opposed to other windows which should created on the stack?
|
|
|
|
|
The Windows object (HWND) gets destroyed like any other window, when DestroyWindow() is called.
The MFC CFrameWnd object is destroyed in response to the WM_NCDESTROY message (see
CFrameWnd::PostNcDestroy()).
tom groezer wrote: as opposed to other windows which should created on the stack?
Not necessarily true - The same scope rules apply as always. If you want a window to exist after
a function/method returns, the stack might not be a good place for the object.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
AfxRegisterWndClass or AfxRegisterClass or RegisterClass. What is the difference between the three and when should be used what?
|
|
|
|
|
tom groezer wrote: What is the difference between the three...
The first two are MFC. AfxRegisterClass() is a thin wrapper around RegisterClass() , and is a bit more sophisticated than AfxRegisterWndClass() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
RegisterClass[^] is a Windows API, and is used internally by AfxRegisterClass and
AfxRegisterWndClass.
The documentation for AfxRegisterClass and AfxRegisterWndClass (in the remarks section) describes
their usage:
AfxRegisterClass[^]
AfxRegisterWndClass[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
http://msdn2.microsoft.com/en-us/library/ms786690.aspx
It says :
Include Qedit.h. This header file is not compatible with Microsoft® Direct3D® headers later than version 7.
My application must do both VMR9 rendering and sample grabbing.
But there are many problems when i include d3d9.h+vmr9.h with qedit.h at the same time , it gives lots of errors when trying to build
how can i use vmr9 filter and samplegrabber filter at the same time ?
|
|
|
|
|
|
Thanks but what about audio streams ?
And what about processing imag , will it only give image or can it give chance of processing image buffer just in sample-grabber ?
|
|
|
|
|
Well this is unfortunate, but based on messing with this and searching for an answer...
It looks like the only workaround is to separate VMR-related and SampleGrabber-related code into
two different source modules. The two modules will need to include a different set of header
files (which means including them in a pre-compiled header won't work).
Another alternative is to make your own custom grabber filter. The Grabber Filter Sample in the
DirectShow SDK implements one that already works. You'd want to change the names and GUIDs to
your own to differentiate it from the SDK sample filter.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
What exactly is dlg subclass ?.I went through the docs of CWnd::SubclassDlgItem but did niot understand.
Is it regarding message handling routines when the windows controls are placed on a dialog?
How does subclassing help?
Prithaa
|
|
|
|
|
prithaa wrote: What exactly is dlg subclass ?.
In general, a subclass is this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To understand window subclassing and how the MFC framework subclasses windows, you should have a
good understanding of the fundamentals of Windows programming: Windowing[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
What is the relationship between subclassed dialog item and
DLGTEMPLATE d;
d.cdit
One of the demo code given for "Dynamic creation of Dialogs" saya
if a dialogitem is subclassed only then it can be added to to d.cdit.
This part of subclassed dialog item is what I did not understand.
Thanks for all your replies and cooperation.
Prithaa
|
|
|
|
|
prithaa wrote: What is the relationship between subclassed dialog item and
DLGTEMPLATE d;
d.cdit
None that I know of. The template is used for dialog creation.
Once a dialog and its items (controls) have been created then you can subclass them.
prithaa wrote: One of the demo code given for "Dynamic creation of Dialogs" saya
if a dialogitem is subclassed only then it can be added to to d.cdit.
That doesn't make sense. Do you have a link to that? Is it the MFC DLGTEMPL Sample?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hello ,
Thanks,for all your support.
I have understood almost everyting about the dialogs with your help.
One last question about subclass.
You said that
Once a dialog and its items (controls) have been created then you can subclass them.
What does the above statement mean?
I was referring to Dynamic Dialog Class by Marcel
Thanks
Prithaa
|
|
|
|
|
prithaa wrote: You said that
Once a dialog and its items (controls) have been created then you can subclass them.
In order to subclass a window (or control) it needs to have an HWND. That means the window has to
exist (be created) before you can subclass it.
Reminder/Note: In MFC, windows are created in two steps -
1) A C++ object (CWnd) is created
2) A window object (HWND) is created
To attach an MFC C++ object (CWnd) to a control in a dynamically created dialog (which already
has a valid HWND), you need to force the subclass to occur (usually this is done by the MFC DDE
mechanism), which is what you use CWnd::SubclassDlgItem() for. Once MFC has the control
subclassed, it can pass messages through the message map mechanism as usual.
You don't HAVE to subclass the controls of the dynamically created dialog. You only need to do
it if you need to associate them with an MFC object or provide special message handling beyond
what the control already does.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|