| View previous topic :: View next topic |
| Author |
Message |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 4:09 pm Post subject: C++ a little code help |
|
|
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 |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Mon Sep 15, 2008 5:05 pm Post subject: |
|
|
Double click on the error thing, and tell us what line it selects.
_________________
|
|
| Back to top |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:15 pm Post subject: |
|
|
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 |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Mon Sep 15, 2008 5:23 pm Post subject: |
|
|
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 |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:33 pm Post subject: |
|
|
| for some reason, i cant see that. i backclicked the soultion anf opened up all the menus
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Mon Sep 15, 2008 5:33 pm Post subject: |
|
|
_________________
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Sep 15, 2008 5:39 pm Post subject: |
|
|
| 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
_________________
|
|
| Back to top |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:39 pm Post subject: |
|
|
thank you very much sponge, but now i have a whole list of errors
| 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 |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Sep 15, 2008 5:42 pm Post subject: |
|
|
Err....donnt do "" around the includes. Use <> instead. That's all I can think of.
_________________
|
|
| Back to top |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:44 pm Post subject: |
|
|
nope did work
thanks anyway
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Sep 15, 2008 5:45 pm Post subject: |
|
|
So did you set it to Multi-Byte?
_________________
|
|
| Back to top |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:48 pm Post subject: |
|
|
| 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 |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Sep 15, 2008 5:51 pm Post subject: |
|
|
| 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 |
|
 |
wizardolu Newbie cheater
Reputation: 0
Joined: 01 Jun 2007 Posts: 23
|
Posted: Mon Sep 15, 2008 5:57 pm Post subject: |
|
|
for some reason, i cannot find the Character set in Properties, ill upload a screen shot.
| Description: |
|
| Filesize: |
115.05 KB |
| Viewed: |
9831 Time(s) |

|
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Sep 15, 2008 5:59 pm Post subject: |
|
|
Correct place. But it under the "General" section. (One under)
_________________
|
|
| Back to top |
|
 |
|