| View previous topic :: View next topic |
| Author |
Message |
hacksign23 Master Cheater
Reputation: 0
Joined: 26 Nov 2006 Posts: 404
|
Posted: Fri Nov 14, 2008 6:31 pm Post subject: C++ memory editing |
|
|
So then I'm using VC++ express edition 2008 edition and when i do FindWindow, it gives me some weird error shit. Also, I want to find the process with its process name so then Minesweeper would be "winmine.exe" or something.
The section is
| Code: |
HWND mine;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
mine = FindWindow(NULL,LPCWSTR("Minesweeper"));
}
|
The error i'm getting is
| Code: |
1>wtf.obj : error LNK2028: unresolved token (0A00000F) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "private: void __clrcall wtf::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@wtf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>wtf.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 "private: void __clrcall wtf::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@wtf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
|
It compiles the code but doesn't link. thanks _________________
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Fri Nov 14, 2008 6:41 pm Post subject: |
|
|
you dont need the LPCWSTR . Just have it as FindWindow( NULL, "MineSweeper" );
Also, for te process part, look into hProcessSnap etc. |
|
| Back to top |
|
 |
hacksign23 Master Cheater
Reputation: 0
Joined: 26 Nov 2006 Posts: 404
|
Posted: Fri Nov 14, 2008 7:15 pm Post subject: |
|
|
lol for the LPCWSTR part, it gives me an error if i don't soo... yea _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Nov 14, 2008 7:59 pm Post subject: |
|
|
I don't know how pinvokeing works in managed C++.
It's nasty. |
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Fri Nov 14, 2008 10:23 pm Post subject: |
|
|
| Code: | [DllImport("user32.dll")]
extern IntPtr FindWindow(String^ lpClassName, String^ lpWindowName); |
| Code: | | IntPtr hWnd = FindWindow(nullptr, "MineSweeper"); |
That should work, but why bother with interop when you can just as easily use the process class?
| Code: | | using namespace System::Diagnostics; |
| Code: | array<Process^>^ Processes = Process::GetProcessesByName("winmine");
for each(Process^ p in Processes)
{
MessageBox::Show(p->MainWindowTitle->ToString());
} |
If you are just starting out with .net, do yourself a favour and switch to c#. Managed c++ is a pain in the ass. |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Nov 14, 2008 11:50 pm Post subject: |
|
|
Yeah, managed C++ is fugly, and is no longer supported. Use native code, or C#.
You can use the process class as stated above, it will do all you need and more. |
|
| Back to top |
|
 |
|