![]() |
| Register | |||||||
| General Software This is the forum for general discussions about software. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Administrator! Join Date: 21 Apr 2003 Location: Penang
Posts: 29,820
Reputation: 2162 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Rep Power: 56 | Well, I want to start to pick up on programming again. I wish to create a tool for stress testing Windows Vista system through running reboot or sleep in a definite loop which will increase a counter upon each reboot/sleep&wakeup completed. Anyway I can do that? I hope someone can point me to somewhere for more info. Thanks.
__________________ | Intel Core 2 Duo E6850 @ 3.2Ghz | ASUS P5B-E Plus | G.SKILL 2x1GB DDR2 800 | 6 HDDs (2TB+ only ![]() Blog : Dashken's I-Blog Gallery : Dashken's I-Paintings |
| | |
| SPONSOR |
| |
| | #2 (permalink) |
| shutdown -h now Join Date: 15 Aug 2003 Location: in front of my pc
Posts: 6,002
Reputation: 1078 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Rep Power: 22 | I think you can write a batch script of a vb script that does that, and also make it a part of you boot up sequence <-- not such a good idea cos you wont be able to boot up to windows without getting rid of that script from the run level
__________________ "God does not play dice with the universe." - Albert Einstein (1879-1955) http://edward-lim.blogspot.com |
| | |
| | #3 (permalink) |
| ARP Webmaster Join Date: 13 Oct 2002 Location: http://atpeaz.placidthoughts.com/
Posts: 8,515
Reputation: 1673 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Rep Power: 31 | Hmmm sounds like you'd need to invoke the windows API to get it to restart. increment counters should not be a problem. it will just be reading and writing to a text file. that's the simplest method to keep track of the number of runs. once u program this application, run it as a startup program. As to where and how, Hmm i can try to find it but you'd probably have to refer to the latest MSDN for Vista's APIs. |
| | |
| | #4 (permalink) |
| ARP Webmaster Join Date: 13 Oct 2002 Location: http://atpeaz.placidthoughts.com/
Posts: 8,515
Reputation: 1673 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Rep Power: 31 | looks like the API u need to invoke is ExitWindowsEx() http://homepages.tesco.net/J.deBoyne...n-process.html http://msdn2.microsoft.com/en-gb/library/aa376868.aspx A sample on VB.NET http://vbnet.mvps.org/index.html?cod...twindowsex.htm |
| | |
| | #5 (permalink) |
| I'm a regular Join Date: 3 Mar 2005
Posts: 471
Reputation: 142 ![]() ![]() Rep Power: 5 | I think this should do most of what you want to do. Code: #include <windows.h>
/*------------------------------------------------------------------------
Procedure: SystemReboot ID:1
Purpose: The SystemReboot function either logs off the
current user, shuts down the system, or shuts down
and restarts the system. This is layer function
to ExitWindowsEx. It ask necesory privilege under
WinNT.
Input: Mode - Specifies the type of shutdown.
EWX_LOGOFF Shuts down all processes running in the
security context of the process that called the
ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the
power. The system must support the power-off feature.
EWX_REBOOT Shuts down the system and then restarts
the system.
EWX_SHUTDOWN Shuts down the system to a point at
which it is safe to turn off the power. All file
buffers have been flushed to disk, and all running
processes have stopped. If the system supports the
power-off feature, the power is also turned off.
EWX_FORCE Forces processes to terminate. When this
flag is set, the system does not send the
WM_QUERYENDSESSION and WM_ENDSESSION messages. This
can cause the applications to lose data. Therefore,
you should only use this flag in an emergency.
Output:
Errors: If the function succeeds, the return value is
nonzero. If the function fails, the return value is
zero. To get extended error information, call
GetLastError.
------------------------------------------------------------------------*/
BOOL WINAPI SystemReboot(UINT mode)
{
BOOL ret;
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
GetVersionEx (&vi);
// Do we have Windows NT/W2K/XP
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
ret = FALSE;
// open access privilege list.
if (OpenProcessToken (GetCurrentProcess (),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
tp.PrivilegeCount = 1; // one privilege to set
// Ask the "shutdown" LUID
LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME,
&tp.Privileges[0].Luid);
// enable it
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get the shutdown privilege for this process.
AdjustTokenPrivileges (hToken, FALSE, &tp, 0, NULL, 0);
// Cannot test the return value of AdjustTokenPrivileges.
ret = (GetLastError () == ERROR_SUCCESS);
}
}
else
ret = TRUE;
return (ret ? ExitWindowsEx (mode, 0) : FALSE);
} |
| | |
| | #6 (permalink) |
| Administrator! Join Date: 21 Apr 2003 Location: Penang
Posts: 29,820
Reputation: 2162 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Rep Power: 56 | Wow... thanks everyone! Appreciate it. Now, I have to dig deep and find any programming skills that I've still got left.
__________________ | Intel Core 2 Duo E6850 @ 3.2Ghz | ASUS P5B-E Plus | G.SKILL 2x1GB DDR2 800 | 6 HDDs (2TB+ only ![]() Blog : Dashken's I-Blog Gallery : Dashken's I-Paintings |
| | |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| NVIDIA PRODUCTS BOLSTER GRAPHICS CAPABILITIES OF MICROSOFT WINDOWS VISTA! | Dashken | News | 0 | 11th Jan 2006 07:21 PM |
| Microsoft Advices to Avoid Integrated Graphics Cores for Windows Vista! | Dashken | News | 16 | 9th Aug 2005 01:17 PM |
| First potential virus risk for Windows Vista found! | Dashken | News | 0 | 5th Aug 2005 03:55 PM |