>I am trying to write a very simple C program to power off
>my PC. I created a Visual C++ win32 application with the
>following lines:
>
>
>#include "stdafx.h"
>#include "windows.h"
>
>void main(int argc, char* argv[]) {
> printf("Shutting down ...");
> ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0);
>}
>
>
>It just didn't work! The program simply exited
>without doing a thing. Please help.
If you read the MSDN docs, ExitWindowsEx() doesn't function under Win95 from a console app. You'll need to create a WinApp to use the API call, even if you never bring the app's Window to a visible state. I think I already directed you to Jeff Richter's
Advanced Windows for more details on the differences between a console app and a GUI-based app.
In addition, the system will not power off unless there's ACPI/APM support in the system BIOS and Power Management is enabled in Control Panel.
>
>BTW, is there a smaller C compiler than Visual C++
>that could communicate with Win95?