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 


[Question] C++ Write / Read from a INI file
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
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Sat Aug 01, 2009 11:02 am    Post subject: [Question] C++ Write / Read from a INI file Reply with quote

so i noticed how many trainers can write and read from an INI file
like read values or read if the checkbox is ticked or not..
and i really need it so, how ???
Im really slow in C++ so make it understand able Smile
thanks

_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Sat Aug 01, 2009 11:26 am    Post subject: Reply with quote

[Get|Read|Write]PriavteProfile[String|Int|Section|Struct|SectionNames]
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Aug 02, 2009 4:04 am    Post subject: Reply with quote

ps. microsoft 'recommends' you use registry as .ini files are 'obsolete' now but it's sort of personal choice. some people don't like changes to registry since it makes settings and stuff less easy to port to another machine. and a lot of apps fail to clean up registry properly after uninstalling.

there is one very cool method i read about the other day. which is to save your settings in the executable file itself. then edit the .exe with the new settings every time the user changes them. very cool imo, i'll make an example for that when i'm done with my current project
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Aug 02, 2009 4:12 am    Post subject: Reply with quote

Embedding the settings in your own exe does not sound very useful...


I tried to write my own .ini routines a while ago, but it ended up being more of a pain in that ass than I expected. Can't say I recommend doing it unless you like wasting a lot of time.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Aug 02, 2009 4:19 am    Post subject: Reply with quote

yes i also wrote my own .ini routines a while ago accidentally. this was when i thought of using config files but didn't know msdn supplied some so i coded my own too. mainly is a string parser then you sort of 'tokenise' the contents that you read. pain in the ass considering i did it in asm

why do you not think embedding settings would be useful.. when you take the program to another machine no need to worry about copying a config file or redoing configurations or copying registry keys. just 1 file copy
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Sun Aug 02, 2009 6:35 am    Post subject: Reply with quote

I also got it to work ..
thanks

_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun Aug 02, 2009 12:35 pm    Post subject: Reply with quote

http://forum.cheatengine.org/viewtopic.php?p=1717147&sid=9ab9319404b36751e2a49093fc97d693
http://forum.cheatengine.org/viewtopic.php?p=2750774&sid=50c34acfc62d2195bd05a568a058b36d
And so on.. I had a light/small déjà vu reading this post :P
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Mon Aug 03, 2009 2:57 pm    Post subject: Reply with quote

Guys im having another problem..
when im trying to read if the checkbox is ticked or not it wont work..

Quote:
TCHAR inBuf[80];
GetPrivateProfileStringA("ExtraHacks","SSFly","FALSE",inBuf,80,"C:\\ProSettings.ini");
if(inBuf == FALSE){
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, FALSE,0);
}
else{
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, TRUE,0);
}


That code makes the checkbox true everytime even when the file says its false..
probably the "if" failes so..
how do i fix it?

_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Aug 03, 2009 7:13 pm    Post subject: Reply with quote

FALSE is a typedef for 0

step through in the debugger so you can see that inBuf is actually getting the value you expect it to be.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Aug 04, 2009 1:34 am    Post subject: Reply with quote

couldn't you just do this ?

Code:
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, GetPrivateProfileStringA("ExtraHacks","SSFly","FALSE",inBuf,80,"C:\\ProSettings.ini"),0);
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Aug 04, 2009 2:07 am    Post subject: Reply with quote

Slugsnack wrote:
couldn't you just do this ?

Code:
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, GetPrivateProfileStringA("ExtraHacks","SSFly","FALSE",inBuf,80,"C:\\ProSettings.ini"),0);



GetPrivateProfileString returns a DWORD, the number of characters copied.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Aug 04, 2009 2:18 am    Post subject: Reply with quote

oh misread. thought the IF condition was for the return of that call
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Tue Aug 04, 2009 2:08 pm    Post subject: Reply with quote

i dont get it
everything failes

i tried comparing inBuf to 0 , "0" , "FALSE", false(error) , FALSE
everything fucking failes man..

btw i checked and the function returns FALSE / TRUE
no 0 or 1
so what am i suppost to do

_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Tue Aug 04, 2009 2:17 pm    Post subject: Reply with quote

Pro-surf wrote:
i dont get it
everything failes

i tried comparing inBuf to 0 , "0" , "FALSE", false(error) , FALSE
everything fucking failes man..

btw i checked and the function returns FALSE / TRUE
no 0 or 1
so what am i suppost to do


You can't compare inBuf to "0", it is just a pointer..try copying a string to it, then strcmp to the string you set.

Also, why would you compare the return to 0 or 1 ? Someone just stated that it returns the number of characters copied, so only compare to 0 for failure.

Also, why aren't you using GetPrivateProfileInt ? That seems like a more logical idea than string comparison.
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Tue Aug 04, 2009 2:36 pm    Post subject: Reply with quote

smartz993 wrote:
Pro-surf wrote:
i dont get it
everything failes

i tried comparing inBuf to 0 , "0" , "FALSE", false(error) , FALSE
everything fucking failes man..

btw i checked and the function returns FALSE / TRUE
no 0 or 1
so what am i suppost to do


You can't compare inBuf to "0", it is just a pointer..try copying a string to it, then strcmp to the string you set.

Also, why would you compare the return to 0 or 1 ? Someone just stated that it returns the number of characters copied, so only compare to 0 for failure.

Also, why aren't you using GetPrivateProfileInt ? That seems like a more logical idea than string comparison.


I didnt compare it with 1 or 0
i tried FALSE TRUE which is the same i guess
ill try an Int this time..

EDIT :
man it works ..
you are good

btw didnt hear from you long time
thanks for the help man

EDIT2 :
thats how iv done it if anyone needs it :
Quote:
BOOL outBuf = GetPrivateProfileInt("ExtraHacks","SSFly",0,"C:\\ProSettings.ini");
if(outBuf == 1){
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, TRUE,0);
}
else if(outBuf == 0){
SendMessage (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_SETCHECK, FALSE,0);

_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
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
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