0

For some reason my shutdown function that i'm making won't work.
I get this error:

In function `void shutdown()':
expected `,' or `...' before numeric constant


Here is my coding:

#include <windows.h>

void shutdown();
void shutdown()
{
BOOL WINAPI ExitWindowsEx(UINT EWX_REBOOT,
DWORD SHTDN_REASON_MAJOR_HARDWARE);
return;
}

int main()
{
shutdown();
}

The problem is with the line that starts with BOOL WINAPI. I have tried a bunch of things but none of them work.

2
Contributors
10
Replies
11
Views
8 Years
Discussion Span
Last Post by goody11
0
BOOL WINAPI ExitWindowsEx(UINT EWX_REBOOT,
DWORD SHTDN_REASON_MAJOR_HARDWARE);

This somehow looks like you are declaring a function .
Though what you need is to call it.

I am not a Windows expert but try this.

ExitWindowsEx(UINT EWX_REBOOT,
DWORD SHTDN_REASON_MAJOR_HARDWARE);

Also check if the function is embedded into a namespace.

0
BOOL WINAPI ExitWindowsEx(UINT EWX_REBOOT,
DWORD SHTDN_REASON_MAJOR_HARDWARE);

This somehow looks like you are defining a function .
Though what you need is to call it.

I am not a Windows expert but try this.

ExitWindowsEx(UINT EWX_REBOOT,
DWORD SHTDN_REASON_MAJOR_HARDWARE);

I tried that and got 2 new errors.

In function `void shutdown()':
expected primary-expression before numeric constant
expected primary-expression before "SHTDN_REASON_MAJOR_HARDWARE"

0

I am absolutely sorry,

ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_HARDWARE);

this should work out,

I forgot to remove the data-types in your function.

Though I am worried whether SHTDN_REASON_MAJOR_HARDWARE exists.

0

Thank you it worked. And you were right that SHTDN_REASON_MAJOR_HARDWARE does not exist. MSDN said that I could use it but apparently they lied! Anyway do you know a reason that I could fill in instead for this parameter?

0

I'm trying all of MSDN's reasons but none of them are working. My compiler says that they are all undeclared. I tried putting DWORD in front of them but then it says that it expects a primary-expression before SHTDN_REASON_MAJOR_HARDWARE.

0

I Never Used Windows programming before, But I think that You will need to include a file known as reason.h

#include <reason.h>
0

You were right. I needed to actually download the file and the program worked but my computer didn't restart,the application just closed.

0

Thanks! Everything works great. I'm new to windows.h and trying to learn all of it's functions.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.