I am trying to get to grips with using Windows API functions, but making them work properly is proving difficult.
In VS2015, my C++ code currently produces linker errors whenever I call MessageBox()
or anything similar:
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace System;
int main()
{
Console::WriteLine(L"Hello World");
MessageBox(NULL, L"Stuff", L"Things", MB_OK | MB_ICONEXCLAMATION);
return 0;
}
The errors I get are an unresolved token and an unresolved external symbol, with MessageBoxW
appearing in the messages.
One of the error messages: Error LNK2028 unresolved token (0A0004E9) "extern "C" int stdcall MessageBoxW(struct HWND *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int cdecl MessageBox(struct HWND *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)