|
Hi, all there:
I was doing some stuff on windows update download&install using wuapi, and this done already.
Now I wanna implement a schedule reboot prompts, just like windows os do after auto windows update, which you can select "reboot after XX minites" or "reboot now".
Does anyone know how to implement this? Can WUAPI do this? Or some other way?
Any replay is appreciated!!
above.
|
|
|
|
|
|
Thanks very much for your help!!
I'll check your url
|
|
|
|
|
as far as I know, the only difference between CMutex and CCriticalSection is that CMutex works at the kernel level and so can be used across process boundaries
So why can you specify the timeout with CMutex::Lock method, but not in CCriticalSection::Lock?
CMutex mutex;
mutex.Lock( 1000 );
CCriticalSection critsec;
critsec.Lock( 1000 );
|
|
|
|
|
At the API level, you can use any of the Wait functions like WaitForSingleObject to wait on a mutex but not on a critical section. That is why the MFC wrappers work in a similar fashion.
For a mutex there is an associated handle.
But for a critical section there is not handle.
|
|
|
|
|
midiway wrote: So why can you specify the timeout with CMutex::Lock method, but not in CCriticalSection::Lock?
Because EnterCriticalSection() API does not accepts a timeout parameter
|
|
|
|
|
A critical section is a higher level construct than a mutex. The current critical section wraps a semeaphore it uses for locking when it has to wait. Before it waits it will spin in user mode to avoid the costly transition to kernel mode and thread context switch.
You have two options to use a timeout with a critical section:
1. (Not recommended) Write a function that uses the internal LockSemaphore. You have to duplicate the functionality for EnterCriticalSection() but allow a timeout to be passed to the wait on the semaphore.
2. Spin on TryEnterCriticalSection. Use GetTickCount to check when you time out. Make sure you do this right. Read up on YieldProcessor, SwitchToThread and Sleep/SleepEx. This is only usefull if you _have to_ use a ctirical section and you _have to_ be able to timeout.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi,
as a result of some calculations in my program, a text file of about 15Gb is created. It contains a very, very long list of numbers like this:
32.2216
32.2425
211.372
34.3651
53.2281
118.987
26.7481
198.789
54.2434
110.048
110.031
222.574
109.283
29.8529
When the program reads it afterwards (to make further calculations based on these data), it halts giving this error message:
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_ios::clear
Aborted
I'm using Linux. Can anyone tell me why this happens and if there's a solution? Thanks.
|
|
|
|
|
A simple (?!) work around would be splitting the file.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
15 GB text file?
Which file system you are using?
Величие не Бога может быть недооценена.
modified on Monday, November 2, 2009 3:34 AM
|
|
|
|
|
Hi, I'm using ReiserFS. Wikipedia says that the maximum file size is 8Tb. I guess splitting the file in chunks may be a good option. But anyway, what's the nature of the error?
|
|
|
|
|
Hi, the problem is solved. It was not an issue of how large the file was, but of an index in an array out of script. Thanks for your help!
|
|
|
|
|
Hi,
I tried to read in the some numbers in a file. I did following:
wifstream is(pFileName);
int int1 = 0, int2 = 0;
is >> int1 ;
is >> int2 ;
The "int1" and "int2" are always "0".
What is wrong?
Thanks
modified on Sunday, November 1, 2009 4:41 PM
|
|
|
|
|
What do you see when you open the file manually?
|
|
|
|
|
Hi
I can read in wide string. But I can not read numbers. I can get string by using "read" function. But I can not get anything back using operator ">>".
Thanks,
|
|
|
|
|
I suspect the numbers as you mention are stored as strings in your file.
If it is stored as numbers, it should not make any sense when you open the file manually.
|
|
|
|
|
Yes, I saved them as numbers not string. It tried to read a binary file which has string and numbers. The string was saved as string and numbers is as numbers (not string).
Why wifstream does not read number only string?
How can I correct them?
Thanks,
modified on Monday, November 2, 2009 11:56 AM
|
|
|
|
|
Hi again,
Can someone be helpful and show me a link or a piece of code that allows me to insert into my code so when the user clicks the X button at the top of the client so a message box appear and says "Are you sure you want to exit" along with the event.
Thanks
Andrew McIntyre
|
|
|
|
|
Handle the WM_CLOSE[^] message for the window.
You can put your message box in this handler.
|
|
|
|
|
switch (message)<br />
{<br />
case WM_CLOSE:<br />
MessageBox(NULL, "Are you sure you want to exit?", "Exit", MB_YESNO | MB_ICONEXCLAMATION);<br />
DestroyWindow(hwnd);<br />
break;<br />
}
Can someone help me find a missing identifier and show me where I have to put it.
Thanks
Andrew McIntyre
modified on Sunday, November 1, 2009 3:39 PM
|
|
|
|
|
case WM_CLOSE:
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))
DestroyWindow(hwnd);
return 0;
For MFC it could look like this -
void CYourClass::OnClose()
{
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))
DestroyWindow(hwnd);
}
|
|
|
|
|
Hi. I think I've done something wrong somewhere.
#include <windows.h><br />
<br />
#define WINDOW_WIDTH 1040<br />
#define WINDOW_HEIGHT 750<br />
<br />
const char lpClassName[] = "My Project";<br />
HWND mainWindow;<br />
<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)<br />
{<br />
WNDCLASSEX wc;<br />
wc.style = CS_VREDRAW | CS_HREDRAW;<br />
wc.lpszMenuName = NULL;<br />
wc.lpszClassName = lpClassName;<br />
wc.lpfnWndProc = WindowEvent;<br />
wc.hInstance = hInstance;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);<br />
wc.cbWndExtra = 0;<br />
wc.cbSize = sizeof(wc);<br />
wc.cbClsExtra = 0;<br />
<br />
RegisterClassEx(&wc);<br />
<br />
mainWindow = CreateWindowEx(<br />
NULL,<br />
lpClassName,<br />
"My Project",<br />
WS_OVERLAPPEDWINDOW | WS_VISIBLE,<br />
(GetSystemMetrics(SM_CXSCREEN) / 2) - (WINDOW_WIDTH / 2),<br />
(GetSystemMetrics(SM_CYSCREEN) / 2) - (WINDOW_HEIGHT / 2),<br />
WINDOW_WIDTH,<br />
WINDOW_HEIGHT,<br />
NULL,<br />
NULL,<br />
hInstance,<br />
NULL<br />
);<br />
<br />
if (!mainWindow)<br />
return 0;<br />
<br />
UpdateWindow(mainWindow);<br />
<br />
MSG msg;<br />
<br />
while (1)<br />
{<br />
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
if (msg.message == WM_QUIT)<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
return (int) msg.wParam;<br />
}<br />
LRESULT CALLBACK WindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_CLOSE:<br />
if (MB_YES == MessageBox(hwnd, _T("Are you sure you want to exit?"), _T("Confirmation"), MB_YESNO))<br />
DestroyWindow(hwnd);<br />
<br />
return 0;<br />
break;<br />
}<br />
return DefWindowProc(hWnd, message, wParam, lParam);<br />
}
Andrew McIntyre
|
|
|
|
|
You really must do this on your own.
Change the first parameter of MessageBox from hwnd to hWnd .
|
|
|
|
|
I got three compile errors:
'MB_YES' : undeclared identifier
'_T': identifier not found
'_T': identifier not found
Andrew McIntyre
|
|
|
|
|
Can someone help me with those errors.
Please
Andrew McIntyre
|
|
|
|