CLR C++ FindWindow help[SOLVED]
Hey, i am trying to learn how to make a trainer, and i read the tutorial here on memory hacking, i have created a CLR C++ Project in VC++ and i'm getting a problem with FindWindow.
Here is my code, and bugs i get, can anyone tell me what i might be doing wrong, and why FindWindow isn't working properly.
Test1.h
[php]#pragma once
using namespace System;
using namespace System::Windows::Forms;
ref class CTest1 : public Form
{
public:
CTest1(void);
};[/php]
Test1.cpp
[php]#include "Test1.h"
CTest1::CTest1(void)
{
}[/php]
central.cpp
[php]#include <Windows.h>
#include "Test1.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
Application::Run(gcnew CTest1());
// Find the window of the calculator
HWND hWnd = FindWindow(0, "Calculator");
// The Window Does not Exist
if(hWnd == 0)
{
//MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
}
else
{
//MessageBox(0, "Window exists.", "Error", MB_OK|MB_ICONERROR);
}
return 0;
}[/php]
Currently i am not really trying to do all of the code at once, i want to get FindWindow working first. So the rest will come later.
These are the bugs i get:
I have googled for hours and cannot find an answer, i think i might have to define or include something but i do not know what. If you give code please care to include an explanation of what it does so i can learn for it 
Thanks, Cheers
Here is my code, and bugs i get, can anyone tell me what i might be doing wrong, and why FindWindow isn't working properly.
Test1.h
[php]#pragma once
using namespace System;
using namespace System::Windows::Forms;
ref class CTest1 : public Form
{
public:
CTest1(void);
};[/php]
Test1.cpp
[php]#include "Test1.h"
CTest1::CTest1(void)
{
}[/php]
central.cpp
[php]#include <Windows.h>
#include "Test1.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
Application::Run(gcnew CTest1());
// Find the window of the calculator
HWND hWnd = FindWindow(0, "Calculator");
// The Window Does not Exist
if(hWnd == 0)
{
//MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
}
else
{
//MessageBox(0, "Window exists.", "Error", MB_OK|MB_ICONERROR);
}
return 0;
}[/php]
Currently i am not really trying to do all of the code at once, i want to get FindWindow working first. So the rest will come later.
These are the bugs i get:
1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> central.cpp
1>central.obj : error LNK2028: unresolved token (0A00004A) "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)
1>central.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)
1>c:\users\dave\documents\visual studio 2010\Projects\Test1\Debug\Test1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1> central.cpp
1>central.obj : error LNK2028: unresolved token (0A00004A) "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)
1>central.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)
1>c:\users\dave\documents\visual studio 2010\Projects\Test1\Debug\Test1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks, Cheers


