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++]Could use some help here.

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

Joined: 01 Mar 2008
Posts: 363

PostPosted: Tue Jan 20, 2009 5:16 pm    Post subject: [C++]Could use some help here. Reply with quote

I'm working on a better way to read a text file and convert it to a VK. This is what I got:
Code:
UINT Vk(LPCWSTR lpKeyName)
{
   UINT Vk = NULL;
   LPCWSTR lpAppName = _T("Settings");
   LPCWSTR lpDefault = _T("");
   LPCWSTR lpFileName = _T(".\\Settings.TB");
   DWORD nSize = 255;
   wchar_t *Key = new wchar_t[nSize];
   GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Key, nSize, lpFileName);

   if(lstrcmp(Key, _T("Ctrl")) == 0)
      Vk = VK_CONTROL;
   else if(lstrcmp(Key, _T("Pg Down")) == 0)
      Vk = VK_NEXT;
   else if(lstrcmp(Key, _T("Pg Up")) == 0)
      Vk = VK_PRIOR;
   else if(lstrcmp(Key, _T("End")) == 0)
      Vk = VK_END;
   else if(lstrcmp(Key, _T("Del")) == 0)
      Vk = VK_DELETE;
   else if(lstrcmp(Key, _T("Ins")) == 0)
      Vk = VK_INSERT;
   else if(lstrcmp(Key, _T("Home")) == 0)
      Vk = VK_HOME;
   else if(lstrcmp(Key, _T("Alt")) == 0)
      Vk = VK_LMENU;
   else
      Vk = VkKeyScan(Key);

   return Vk;
}
But I'm having problems with the last part.
Code:
Vk = VkKeyScan(Key);

'VkKeyScanW' : cannot convert parameter 1 from 'wchar_t *' to 'WCHAR'
How do I make it into a WCHAR? I tried putting (WCHAR) before Key like this: VkKeyScan((WCHAR)Key);, but it did nothing at all.

And while I'm at it. How do I read a pointer with the value in double?
I've tried to do as I do with a 4 byte pointer:
Code:
double Exp = *((double*)dwExpBase) + dwExpOffset);
But that does not output anything at all. I also tried
Code:
double Exp = *((DWORD*)dwExpBase) + dwExpOffset);
with the same result.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Jan 20, 2009 10:36 pm    Post subject: Reply with quote

Key[0] To fix the first problem.
Because Key is your string, while VkKeyScan is only looking for a single character, so you simply just point to the first value in the array.

As for the double, the base is going to be 4 bytes anyways, as will the offset, just you want to read 8 bytes instead of 4.

Code:
double dExp = (double)*((DWORD*)dwExpBase + dwExpOffset);


Should work...

_________________
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Wed Jan 21, 2009 12:32 am    Post subject: Reply with quote

Thz lurc. The Key[0] did the trick. As fot he pointer it's still the same as before. It shows a '0' instead of the actual value.
Back to top
View user's profile Send private message
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