| View previous topic :: View next topic |
| Author |
Message |
DaHandy Newbie cheater
Reputation: 0
Joined: 03 Nov 2007 Posts: 18
|
Posted: Wed Dec 01, 2010 8:18 am Post subject: Visual C++ char array to system::string? |
|
|
Hi!
I have just begun to use Visual Studio 2008 to create a keygen. However, I can't set textbox text because my variable is a char*. I have no idea how to convert a char* to system::string.
I have tried this:
| Code: | int point1;
char* value1[5];
SIZE_T stBytes1 = 0;
//The code that gets window handle is here, stores it correctly to var phandle.
ReadProcessMemory(phandle, (LPVOID)0x005F2D2C, &point1, 4, &stBytes1);
ReadProcessMemory(phandle, (LPVOID)point1, &value1, 7, &stBytes1);
char* value1_p = (char*)value1;
String^ StrVal1 = String^(value1_p);
this->textBox1->Text = StrVal1; |
The compiler tells me this:
| Code: | | Error 1 error C2275: 'System::String' : illegal use of this type as an expression |
So what does that actually mean? What's wrong?
Thanks in advance!
EDIT: I also tried this:
| Code: | String^ StrVal1;
StrVal1 = value1_p->toString(); |
Without success though. It gives me this error:
| Code: | | Error 1 error C2039: 'toString' : is not a member of 'System::SByte' |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Dec 01, 2010 9:10 am Post subject: |
|
|
From Google:
http://stackoverflow.com/questions/56561/what-is-the-best-way-to-convert-between-char-and-systemstring-in-c-cli
Another suggestion:
| Code: | char*p="test string...";
System::String *str(p); |
I don't use VC++ so I can't guarantee any of these will work.
Also with your reading code, is the string(s) you are reading pointers or is it just a direct 7char string? If you are reading a 7char string your definition to value1 is incorrect. And you also didn't give enough space to read 7 bytes either.
Actually surprised to see someone using VC++ lol.
_________________
- Retired. |
|
| Back to top |
|
 |
DaHandy Newbie cheater
Reputation: 0
Joined: 03 Nov 2007 Posts: 18
|
Posted: Wed Dec 01, 2010 9:30 am Post subject: |
|
|
Thanks for the reply!
Your code gives me 2 errors:
| Code: | Error 1 error C3699: '*' : cannot use this indirection on type 'System::String'
Error 2 error C2440: 'initializing' : cannot convert from 'char *' to 'System::String ^'
|
So it's still not working.. :/
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Dec 01, 2010 12:08 pm Post subject: |
|
|
| c++/cli is barfo tbh
|
|
| Back to top |
|
 |
DaHandy Newbie cheater
Reputation: 0
Joined: 03 Nov 2007 Posts: 18
|
Posted: Wed Dec 01, 2010 1:04 pm Post subject: |
|
|
Yeah, seems like one...
I got an answer from another forum:
| Code: | | String^ StrVal1 = System::Runtime::InteropServices::Marshal::PtrToStringAnsi(IntPtr((value1)); |
But thanks for the help!
|
|
| Back to top |
|
 |
|