Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Forced poweroff
Message
De
15/04/1999 20:32:49
 
 
À
01/04/1999 22:53:35
Man Wai Chang
Hang Hing Metal Manufacturer
Hung Hom, Hong Kong
Information générale
Forum:
Visual C++
Catégorie:
Autre
Titre:
Divers
Thread ID:
00204524
Message ID:
00208829
Vues:
23
>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?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform