|
I'm not sure what you mean, but if you mean to restart a computer at specified time it is possible of course. Below you have a function for rebooting the computer. It works with all Windows versions. Call it with the in parameter EWX_REBOOT and the system will be rebooted:
BOOL WindowsExitOrReboot(UINT flags)<br />
{<br />
if (IsWindowsNT()) {
HANDLE hToken; <br />
TOKEN_PRIVILEGES tkp; <br />
<br />
SetLastError(ERROR_SUCCESS);<br />
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) <br />
return FALSE;<br />
<br />
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); <br />
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; <br />
<br />
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); <br />
if (GetLastError() != ERROR_SUCCESS) return FALSE;<br />
<br />
if (!ExitWindowsEx(flags | EWX_FORCE, 0)) return FALSE;<br />
return TRUE;<br />
}<br />
else {
if (!ExitWindowsEx(flags, 0)) return FALSE;<br />
return TRUE;<br />
}<br />
}
But if you mean to shut down the computer for a time and then let it start automatically I don't think it is possible. Not without some hardware.
|
|
|
|
|
I actually meant is there any way to turn the computer on automatically at a specific time, when it has been turned off manually. For example could I program the computer to boot up at 8 o'clock every morning?
If not, is there any way to bring the computer out of standby mode in the same way, ie bring the computer out of standby at 8 o'clock every morning.
Thanks
|
|
|
|
|
Hain i think you are seaching for wake on Lan feature type application.
i am able to boot computer through network at giving time.
bascially it functioning is like this->
You send a packet containg the subnet mask of you network to that particular computer which is in off state this feature only feasible for ATX cabinet computer & lan card with wake on lan feature
Happy programming
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
personally, I think you need a external device & program to control the power supply of shut down pc.
|
|
|
|
|
No its not possible. That is set in the bios, and you have no programmatical access to the bios.
|
|
|
|
|
I've been using dundas grid for a while, and my boss asked me about dundas toolkit ... I have a small knowledge of the toolkit, in an earlier versin, and it was ok.
what about roguewave's toolkit ? comparable ?
and are there any other toolkit available ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have used Roguewaves Stingray Toolkit for many years now. It is pretty feature rich and I have had no need to look for alternatives. Unfortuneately I have not used Dundas and therefore can not make direct comparisons.
Perhaps Whitepapers from each would help you make a decision.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi there,
I need a random number generator with float output between 0 and 1 (similar to Math.random() in javascript).
Is there already a function or where to get one?
Thx for your help,
Alex
Don't try it, just do it!
|
|
|
|
|
A true random number generator does not eixst, but you can use rand() for pseudo-random numbers.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hmmm, rand is not very good. a bad resolution and values between 0 and 0x3FFF.
Don't try it, just do it!
|
|
|
|
|
Actually it returns values between 0 and 0x7fff. In any case, if you simply want floating-point values between 0 and 1, couldn't you just divide by RAND_MAX ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
could be a solution, even if it's not the best. but thanks anyway.
Don't try it, just do it!
|
|
|
|
|
well, you can of course generate numbers between 1000 and 2000. Subract 1000 from the random number and divide the result by 1000 into a float.
say rand() outputs 1746:
1746-1000 = 746
746 / 1000 = 0,746
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Thats what I was going to suggest.
How do I print my voice mail?
|
|
|
|
|
Thirded!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Random numbers have been the most popular subject for grad students to study in computer science since before comptuer science was a program at universities! There is good reason for this, and it goes well byond what anyone would write in a simple post.
Start reading, until you understand what question to ask you should not ask the question. Once you know what questions to ask you are well on your way to finding a solution.
Donald Knuth's "Art of Comptuer Programing" is a good start (but a little expensive, and not a simple read). There are plenty of web resources.
|
|
|
|
|
Our program has a requirement to copy files from one computer to another.
The remote computer is mapped to a particular drive on the local computer.
The network is wide open and all users have full control.
We use the MSDN CopyFile function to perform the copy operation.
This works when installing on Windows 2000.
The problem occurs when installing the program on Windows Server 2003
Platform. The error returned by the CopyFile function is "path not found."
The access/stat functions return the same error.
Is there another MSDN funciton to use, or what environment setting does
Win 2003 need?
|
|
|
|
|
MSDN is documentation for several APIs. It is not an API itself.
Have you tried SHFileOperation() with the FO_COPY operation?
Does copying those file outside of your application work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Copying files via explorer works. I did try the SHFileOperation() and had success with it. Thanks.
|
|
|
|
|
Please provide an example of the paths you are trying to copy from and to.
Environment settings will likely not have an effect unless you are using an environment variable, like %WINDIR% .
Peace!
-=- James
Tip for inexperienced drivers: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Found that using SHFileOperation() works nicely.
But an example would be:
LogonUser(); // using username, domain, pwd
ImpersonateLoggedOnUser(); // using logon handle
strcpy(src, "C:\usr\myFile.txt");
// Y is a mapped drive to remote location
strcpy(dest, "Y:\usr\remoteFile.txt");
CopyFile(src, dest, 0);
|
|
|
|
|
The backslashes in the string literals need to be doubled.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello all,
I'm trying to include files to a project on a Windows 2000 system which are located on my Unix account. However, MS VS6 changes the directory names by default to capital letters, and hence Visual C++ cannot find them back anymore, as capital or normal letters are important to UNIX systems. Is there a way to avoid this change to capital letters? I didn't find how to in the Options menu.
I tested if there were access problems, but no, if I create a file and directory with capital letters on my Unix account, I can edit the file. But I would like to avoid this in this project.
Any help would be great, and a huge step forward,
Thanks,
Bart.
|
|
|
|
|
I'm writing a prog that works in the background all the time. So it is loaded on windows startup and unloaded on shutdown. The question is: do I have to perform all the clean up like freeing dynamically allocated memory or uninstalling the hook when windows is being restarted or shut down. If yes then what what message is sent to my application to inform that windows is going to finish it's work? I do not get WM_DESTROY or WM_CLOSE like in the case when I terminate the program myself. Thanks.
|
|
|
|