Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


FindWindow Help C++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Fri Nov 28, 2008 5:51 pm    Post subject: FindWindow Help C++ Reply with quote

Well I'm using VC++ Team System 2008 and it gives me a linking error:
C++ linker wrote:

Error 1 error LNK2028: unresolved token (0A00000F) "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "private: void __clrcall minez::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@minez@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) minez.obj minez
Error 2 error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowA(char const *,char const *)" (?FindWindowA@@$$J18YGPAUHWND__@@PBD0@Z) referenced in function "private: void __clrcall minez::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@minez@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) minez.obj minez
Error 3 fatal error LNK1120: 2 unresolved externals F:\Michael's Magical Folder Of Hippos\programming\C++\minez\Debug\minez.exe 1 minez


and i used
Code:

FindWindow(NULL, (LPCSTR)"Untitled - Notepad");


thanks.

_________________
Back to top
View user's profile Send private message AIM Address
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Nov 28, 2008 6:03 pm    Post subject: Reply with quote

I'm not entirely sure how API calls work within managed C++, but I want to say that you're just missing the include.
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Fri Nov 28, 2008 6:13 pm    Post subject: Reply with quote

Deja vu.. http://forum.cheatengine.org/viewtopic.php?t=316937 Rolling Eyes
Back to top
View user's profile Send private message
BirdsEye
Advanced Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 94

PostPosted: Fri Nov 28, 2008 6:13 pm    Post subject: Reply with quote

Ugh... Please stop using managed C++. I think you have to declare the function just like in VB.NET and C#. Here
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Fri Nov 28, 2008 6:41 pm    Post subject: Reply with quote

Linking error?
Back to top
View user's profile Send private message MSN Messenger
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Fri Nov 28, 2008 11:10 pm    Post subject: Reply with quote

?? o_o well is there an alternative way to get a hwnd? And when i say hwnd, not anything else like process or handle. thanks

PS: all the other functions work like WPM,RPM, etc

_________________
Back to top
View user's profile Send private message AIM Address
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Sat Nov 29, 2008 3:59 am    Post subject: Reply with quote

Code:
#include <windows.h>
#pragma comment(lib, "user32.lib")

Code:
HWND hWnd;

if (IsWindow(hWnd = FindWindowA(NULL, "Untitled - Notepad")))
{
     MessageBoxA(NULL, "Found Notepad!", "Test", 0);
}

Didn't realise how easy it is to use native code within managed c++, link to user32.lib and your project should build correctly.

ps. abandon c++.net Razz
Back to top
View user's profile Send private message
BirdsEye
Advanced Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 94

PostPosted: Sat Nov 29, 2008 9:33 am    Post subject: Reply with quote

Oh yea, he's right. I've never used C++.NET so beware... I'm not sure if this is the correct method or anything. If you include your headers and link against the USER32 library, it still would give you an ambigious symbol error. HOWEVER, (I got this from messin' around) if you type:
Code:
::
it will give you a list of alot of Win32 API and they function right. See:
Code:

   private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            
             if(!::FindWindow(TEXT("Notepad"), NULL))
                ::MessageBox(0, TEXT("Error!"), TEXT("Error!"), MB_OK);
             else
                ::MessageBox(0, TEXT("Found!"), TEXT("Found!"), MB_OK);
          }
   };
}
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Sat Nov 29, 2008 10:48 am    Post subject: Reply with quote

Yea, you can avoid the ambiguity by using MessageBoxA, will save you from using the TEXT() macro too.
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat Nov 29, 2008 12:28 pm    Post subject: Reply with quote

sloppy wrote:
Yea, you can avoid the ambiguity by using MessageBoxA, will save you from using the TEXT() macro too.


Never specify A or W. Use MessageBox because the tchar.h header will correctly change it to A or W depending on whether UNICODE is defined. The TEXT() is part of tchar. It adds a L infront of the string if UNICODE is defined. This makes it so that you can change from Unicode to ANSI with a simple change in the project settings.
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Sun Nov 30, 2008 3:42 am    Post subject: Reply with quote

Good advice, excuse my sloppy coding practices. Razz
Back to top
View user's profile Send private message
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Sun Nov 30, 2008 7:38 pm    Post subject: Reply with quote

wowawea it is working now. thanks! oh one more thing:
Code:

         LPCWSTR windowtextaa = NULL;

         //finds windowtextb(before)

         windowtexta=windownameTextbox->Text;//puts text into windowtexta

         windowtextaa = (LPCWSTR)(Marshal::StringToHGlobalAnsi(windowtexta).ToPointer());//windowtexta
         MessageBox::Show(windowtexta);




         if (!SetWindowText(mineHwnd,windowtextaa)) {
            MessageBox::Show("fail D:","D:");
         }


Marshal::FreeHGlobal((IntPtr((void*)windowtextaa)));

I'm using that to convert it to the LPCWSTR crap, but when i put text into the text box, the window name turns into chinese crap o_o
for example:
i put in "aaa" and it comes out whatever is in the screen shot. I don't know what it is. any help?



fail.GIF
 Description:
 Filesize:  1.85 KB
 Viewed:  7387 Time(s)

fail.GIF


Back to top
View user's profile Send private message AIM Address
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Sun Nov 30, 2008 8:51 pm    Post subject: Reply with quote

Marshal::StringToHGlobalUni(..)
Back to top
View user's profile Send private message
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Sun Nov 30, 2008 9:41 pm    Post subject: Reply with quote

sloppy wrote:
Marshal::StringToHGlobalUni(..)

Very Happy thanks

_________________
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites