I never programmed a winapi so i have a little problem here .
I need turn off my pc from my application .
I found this example link text the
This is a bit much for the comments on Daniel's answer, so I'll put it here.
It looks like your main issue at this point is that your process isn't running with the priveleges required to perform a system shutdown.
The docs for ExitWindowsEx contain this line:
To shut down or restart the system, the calling process must use the
AdjustTokenPrivileges
function to enable theSE_SHUTDOWN_NAME
privilege. For more information, see Running with Special Privileges.
They also have some example code. In a pinch, you can just copy that.