Hey so I have recently been trying to port a bunch of my projects to Visual Studios 2010 and have run into an issue with a number of projects written in C++. Here is the code and compiler error:
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <fstream>
#include <stdio.h>
#include <iostream>
using namespace std;
HHOOK hHook;
char filePath[MAX_PATH];
HMODULE getCurH;
HKEY hKey;
HWND Regedit;
DWORD WINAPI DesWindows(LPVOID);
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
typedef struct tagKBDLLHOOKSTRUCT
{
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
DWORD dwExtraInfo;
}
Code:
1>------ Build started: Project: logger_vuni, Configuration: Debug Win32 ------
1> main.cpp
1>c:\documents and settings\hp_administrator\my documents\c++ workspace\windows programs\keylogger vuniversity\logger_vuni\logger_vuni\main.cpp(22): error C2011: 'tagKBDLLHOOKSTRUCT' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(943) : see declaration of 'tagKBDLLHOOKSTRUCT'
1>c:\documents and settings\hp_administrator\my documents\c++ workspace\windows programs\keylogger vuniversity\logger_vuni\logger_vuni\main.cpp(50): error C2027: use of undefined type 'tagKBDLLHOOKSTRUCT'
1> c:\program files\microsoft sdks\windows\v7.0a\include\winuser.h(943) : see declaration of 'tagKBDLLHOOKSTRUCT'
1>c:\documents and settings\hp_administrator\my documents\c++ workspace\windows programs\keylogger vuniversity\logger_vuni\logger_vuni\main.cpp(50): error C2227: left of '->vkCode' must point to class/struct/union/generic type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The code segment I provided is the first couple lines of a project, it defines a structure that is later used by a windows API keyboard hook. It compiles fine on VC++ 6 but due to the fact that VC++ 6 is old and has little support I thought switching to 2010 made good sense. Guessing by the compiler output I am using an include that is defined somewhere else as well, and Visual C++ 2010 wont have it! Can someone please tell me what I need to do to my includes to stop this error.