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 


C++ a little code help
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 4:09 pm    Post subject: C++ a little code help Reply with quote

okay i have done many programming languages in the past and just comeing back to C++.
here the code that i was trying to test
(it was copied)

Code:

// fcvx.cpp : main project file.

#include "stdafx.h"

#include "windows.h"
#include "WinUser.h"
#include <iostream>

using namespace std;

LRESULT InjectMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
   WNDPROC WndProc;
   LRESULT lRET = 0;

   WndProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC);
   if (WndProc != NULL)
      lRET = CallWindowProc(WndProc, hWnd, uMsg, wParam, lParam);
   return lRET;
}

int main() {
   while (true) {
      if ((GetAsyncKeyState(0x73)<0)) {
         HWND hWndE = FindWindow(0, "MapleStoryClass");

         PostMessage(hWndE, WM_CHAR, 'A', 0);
      }

      Sleep(1);
   }
}

this was in MVC++ and the error is
Code:

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


thank you in advance
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Mon Sep 15, 2008 5:05 pm    Post subject: Reply with quote

Double click on the error thing, and tell us what line it selects.
_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:15 pm    Post subject: Reply with quote

sorry for that the line it selects is
Code:

        HWND hWndE = FindWindow(0, "MapleStoryClass");


and the actual error is
Code:

1>.\fcvx.cpp(24) : error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Mon Sep 15, 2008 5:23 pm    Post subject: Reply with quote

Then convert it to LPCWSTR? Just use a multi-byte character set. Right click your solution -> Properties -> Character Set -> Multibyte.
_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:33 pm    Post subject: Reply with quote

for some reason, i cant see that. i backclicked the soultion anf opened up all the menus
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Mon Sep 15, 2008 5:33 pm    Post subject: Reply with quote

Code:
L"MapleStoryClass"

_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Sep 15, 2008 5:39 pm    Post subject: Reply with quote

wizardolu wrote:
sorry for that the line it selects is
Code:

        HWND hWndE = FindWindow(0, "MapleStoryClass");


and the actual error is
Code:

1>.\fcvx.cpp(24) : error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'


Also, the classname goes in the first param, and the window name goes in the second. so:

Code:
FindWindow ("MapleStoryClass", NULL);


is correct. Unless the game window name os the game is callled MapleStoryClass Rolling Eyes

_________________
Back to top
View user's profile Send private message Send e-mail
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:39 pm    Post subject: Reply with quote

thank you very much sponge, but now i have a whole list of errors

Shocked

Code:

1>fcvx.obj : error LNK2028: unresolved token (0A000299) "extern "C" int __stdcall PostMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?PostMessageW@@$$J216YGHPAUHWND__@@IIJ@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>fcvx.obj : error LNK2028: unresolved token (0A00029A) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>fcvx.obj : error LNK2028: unresolved token (0A00029B) "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>fcvx.obj : error LNK2028: unresolved token (0A00029C) "extern "C" long __stdcall CallWindowProcW(long (__stdcall*)(struct HWND__ *,unsigned int,unsigned int,long),struct HWND__ *,unsigned int,unsigned int,long)" (?CallWindowProcW@@$$J220YGJP6GJPAUHWND__@@IIJ@Z0IIJ@Z) referenced in function "long __cdecl InjectMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?InjectMessage@@$$FYAJPAUHWND__@@IIJ@Z)
1>fcvx.obj : error LNK2028: unresolved token (0A00029D) "extern "C" long __stdcall GetWindowLongW(struct HWND__ *,int)" (?GetWindowLongW@@$$J18YGJPAUHWND__@@H@Z) referenced in function "long __cdecl InjectMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?InjectMessage@@$$FYAJPAUHWND__@@IIJ@Z)
1>fcvx.obj : error LNK2019: unresolved external symbol "extern "C" long __stdcall CallWindowProcW(long (__stdcall*)(struct HWND__ *,unsigned int,unsigned int,long),struct HWND__ *,unsigned int,unsigned int,long)" (?CallWindowProcW@@$$J220YGJP6GJPAUHWND__@@IIJ@Z0IIJ@Z) referenced in function "long __cdecl InjectMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?InjectMessage@@$$FYAJPAUHWND__@@IIJ@Z)
1>fcvx.obj : error LNK2019: unresolved external symbol "extern "C" long __stdcall GetWindowLongW(struct HWND__ *,int)" (?GetWindowLongW@@$$J18YGJPAUHWND__@@H@Z) referenced in function "long __cdecl InjectMessage(struct HWND__ *,unsigned int,unsigned int,long)" (?InjectMessage@@$$FYAJPAUHWND__@@IIJ@Z)
1>fcvx.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall PostMessageW(struct HWND__ *,unsigned int,unsigned int,long)" (?PostMessageW@@$$J216YGHPAUHWND__@@IIJ@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>fcvx.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>fcvx.obj : error LNK2019: unresolved external symbol "extern "C" short __stdcall GetAsyncKeyState(int)" (?GetAsyncKeyState@@$$J14YGFH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)


i think i messed up the code

Agian thank you sponge,Overload and
samuri25404
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Sep 15, 2008 5:42 pm    Post subject: Reply with quote

Err....donnt do "" around the includes. Use <> instead. That's all I can think of.
_________________
Back to top
View user's profile Send private message Send e-mail
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:44 pm    Post subject: Reply with quote

nope did work
thanks anyway
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Sep 15, 2008 5:45 pm    Post subject: Reply with quote

So did you set it to Multi-Byte?
_________________
Back to top
View user's profile Send private message Send e-mail
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:48 pm    Post subject: Reply with quote

no i did not know how, so i put an "L" in front of the string. do i still need to convert and if so, how?
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Sep 15, 2008 5:51 pm    Post subject: Reply with quote

wizardolu wrote:
no i did not know how, so i put an "L" in front of the string. do i still need to convert and if so, how?


Like Overload said

Right click your solution -> Properties -> Character Set -> Multibyte.

_________________
Back to top
View user's profile Send private message Send e-mail
wizardolu
Newbie cheater
Reputation: 0

Joined: 01 Jun 2007
Posts: 23

PostPosted: Mon Sep 15, 2008 5:57 pm    Post subject: Reply with quote

for some reason, i cannot find the Character set in Properties, ill upload a screen shot.


untitled.JPG
 Description:
screenshot
 Filesize:  115.05 KB
 Viewed:  9832 Time(s)

untitled.JPG


Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Sep 15, 2008 5:59 pm    Post subject: Reply with quote

Correct place. But it under the "General" section. (One under)
_________________
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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