I am recieving the following errors when I attempt to build and run my code in Visual Studio Express 2010:
1> Generating Code...
1>Purple Health.obj : error LNK2028: unresolved token (0A000035) "extern "C" int __stdcall ExitWindowsEx(unsigned int,unsigned long)" (?ExitWindowsEx@@$$J18YGHIK@Z) referenced in function "private: void __clrcall PurpleHealth::FormOutOfTime::btnLogout_Click(class System::Object ^,class System::EventArgs ^)" (?btnLogout_Click@FormOutOfTime@PurpleHealth@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>FormLauncher.obj : error LNK2028: unresolved token (0A000031) "extern "C" int __stdcall ExitWindowsEx(unsigned int,unsigned long)" (?ExitWindowsEx@@$$J18YGHIK@Z) referenced in function "private: void __clrcall PurpleHealth::FormOutOfTime::btnLogout_Click(class System::Object ^,class System::EventArgs ^)" (?btnLogout_Click@FormOutOfTime@PurpleHealth@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>FormLauncher.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ExitWindowsEx(unsigned int,unsigned long)" (?ExitWindowsEx@@$$J18YGHIK@Z) referenced in function "private: void __clrcall PurpleHealth::FormOutOfTime::btnLogout_Click(class System::Object ^,class System::EventArgs ^)" (?btnLogout_Click@FormOutOfTime@PurpleHealth@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Purple Health.obj : error LNK2001: unresolved external symbol "extern "C" int __stdcall ExitWindowsEx(unsigned int,unsigned long)" (?ExitWindowsEx@@$$J18YGHIK@Z)
1>C:\Users\Graham\documents\visual studio 2010\Projects\Purple Health\Debug\Purple Health.exe : fatal error LNK1120: 3 unresolved externals
My code looks like this (With the unimportant bits edited out):
#include "FormParentalOverride.h"
#include "Windows.h"
#include <iostream>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#pragma once
namespace PurpleHealth {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Text;
public ref class FormOutOfTime : public System::Windows::Forms::Form
{
private: System::Void btnLogout_Click(System::Object^ sender, System::EventArgs^ e) {
ExitWindowsEx(EWX_LOGOFF, SHTDN_REASON_MAJOR_APPLICATION);
//ExitWindows(0, 0);
}
};
}
Any suggestions are greatly appreciated!
Add User32.dll to your link stage.
Note: Name is misleading inasmuch that the 64 and 32 bit versions are both called user32.