NOOB (06-23-2011)
I am getting compiler errors with my use of GetAsyncKeyState, but I am not sure why.
These are my includes.
The function is:Code:#include "stdafx.h" #include <iostream> #include <string> #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <WinNT.h> #include <WinDef.h> #using <mscorlib.dll> using namespace System; using namespace std;
The function is declared before the main function.Code:DWORD WINAPI tm1(LPVOID) { CreateThread(NULL, NULL, tm2, NULL, NULL, NULL); do { if(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_DELETE)) { system("start program.exe"); HANDLE console2 = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(console2, x++); cout << "denied!"; x++; } } while(TRUE); return 0; }
NOOB (06-23-2011)
I dont know but i think the error is here:
What if you try:Code:if(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_DELETE))
But idk really.Code:if(GetAsyncKeyState(VK_CONTROL)){ if(GetAsyncKeyState(VK_MENU)){ if(GetAsyncKeyState(VK_DELETE)){ // FUNCTION } } }
NOOB (06-23-2011)
NOOB (06-23-2011)
NOOB (06-23-2011)
Errors:
Code:error LNK2028: unresolved token (0A000353) "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "unsigned long __stdcall tm1(void *)" (?tm1@@$$FYGKPAX@Z) error LNK2019: unresolved external symbol "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "unsigned long __stdcall tm1(void *)" (?tm1@@$$FYGKPAX@Z)
NOOB (06-23-2011)
@yodaliketaco
Code:#include "stdafx.h" #include <iostream> #include <string> #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <WinNT.h> #include <WinDef.h> #using <mscorlib.dll> using namespace System; using namespace std;there ya goCode:DWORD WINAPI tm1(LPVOID) { CreateThread(NULL, NULL, tm2, NULL, NULL, NULL); do {//bool them as true if control is held, menu is held, and delete is held. bool Control = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0; bool Menu = (GetAsyncKeyState(VK_MENU) & 0x8000) != 0; bool Delete =(GetAsyncKeyState(VK_DELETE) & 0x8000) != 0; if(Control && Menu && Delete) //If all 3 are held at once { system("start program.exe"); HANDLE console2 = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(console2, x++); cout << "denied!"; x++; } } while(true);//I prefer this return NULL;//Same /\ }
Lyoto Machida (06-12-2011),NOOB (06-23-2011)
@CAFlames
That still gives the same compiler errors. I've never had this problem with GetAsyncKeyState before.
NOOB (06-23-2011)
NOOB (06-23-2011),yodaliketaco (06-12-2011)
Control.ModifierKeys wraps GetKeyState in managed C++, don't know about an alternative for GetAsyncKeyState
Ah we-a blaze the fyah, make it bun dem!
NOOB (06-23-2011)
I am facepalm. Linker errors because multiple of the same includes.
Windows.h already includes the WinNT and WinDef or the includes in windows.h includes them.
Just include windows.h
Last edited by Auxilium; 06-12-2011 at 01:05 PM.
Hell_Demon (06-12-2011),NOOB (06-23-2011),yodaliketaco (06-12-2011)
NOOB (06-23-2011)
Are you trying to mix C++ and C# or using managed C++?
looks managed to me.Code:#using <mscorlib.dll> using namespace System;
If you're trying to compile into a form-based application, that code won't work.
Last edited by mmbob; 06-12-2011 at 01:23 PM.
NOOB (06-23-2011)
NOOB (06-23-2011)
NOOB (06-23-2011)
NOOB (06-23-2011)