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 


[VB6] Reading values from .INI and use it in flash trainer

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

Joined: 21 Jan 2006
Posts: 160
Location: Singapore

PostPosted: Tue Jan 08, 2008 12:40 pm    Post subject: [VB6] Reading values from .INI and use it in flash trainer Reply with quote

Hi there, I have a question about VB6.
How do you actually read values from a INI and used it in my flash trainer,
Example one of the guy who created his trainer, he also include a system.ini

Code:
[Default]
Text12=commando
Text11=none
Text10=none
Text9=life
Text8=ammo
Text7=bomb
Text6=Variable 4
Text5=
Text4=life_left
Text3=slug_left
Text2=bomb_left
Text1=http://www.miniclip.com/games/commando/en/commando.swf?mc_gamename=Commando&mc_hsname=1760


I want the flash trainer to read the variables and values from the ini file, but I don't know how. Oh one more thing, I have no knowledge for VB XD

Thanks!

_________________
Quote:
"Give a man a fish and he will eat for a day. Teach a man to fish and he will eat for the rest of his life."

Read it, learn it and love it!
Back to top
View user's profile Send private message
Michel
Expert Cheater
Reputation: 0

Joined: 16 May 2007
Posts: 214
Location: The Netherlands

PostPosted: Tue Jan 08, 2008 12:59 pm    Post subject: Reply with quote

http://www.vbaccelerator.com/home/vb/Code/Libraries/Registry_and_Ini_Files/Easy_Ini_File_Access/article.asp

All you need.
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Tue Jan 08, 2008 1:09 pm    Post subject: Reply with quote

GetPrivateProfileString() will do the trick. Even though you don't know vb, you can use c++. You have three options: MFC, ATL, or pure win32. MFC would be the best choice for activex controls.

Use of GetPrivateProfileString
Code:

wchar_t wcDir[] = L"c:\\system.ini";
wchar_t wcRetVal[101] = { 0 };

GetPrivateProfileString(L"Default", L"Text1", NULL, wcRetVal, 101, wcDir);


Where default is, that is where you put in the section header. Where Text1 is, that is where you put the variable name. Where NULL is, that is what will get returned if no key is found (the variable you entered). wcRetVal will contain the value of the key. 101 is the buffer size. wcDir tells GetPrivateProfileString where the .ini is. Hope this helped. If you want to do it in vb, it's practically the same. All you have to do is import the function.
Back to top
View user's profile Send private message
hackerkts
Expert Cheater
Reputation: 0

Joined: 21 Jan 2006
Posts: 160
Location: Singapore

PostPosted: Tue Jan 08, 2008 9:53 pm    Post subject: Reply with quote

After reading and trying, I still don't understand a single thing.. >.<
Oh ya, I have any knowledge for C++ too. Crying or Very sad

_________________
Quote:
"Give a man a fish and he will eat for a day. Teach a man to fish and he will eat for the rest of his life."

Read it, learn it and love it!
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Wed Jan 09, 2008 2:49 am    Post subject: Reply with quote

Heres a quick example:

Put this in a module:

Code:
Option Explicit

Private Declare Function GetPrivateProfileString Lib "KERNEL32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As Any, ByVal lpKeyName As Any, ByVal lpDefault As Any, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Public Function ReadKey(strSection As String, strKey As String) As String

    Dim strPath As String
    strPath = App.Path & "\variables.ini"
   
    Dim strDefault  As String
    Dim strBuffer   As String
   
    strDefault = 0
    strBuffer = Space$(255)
    Call GetPrivateProfileString(strSection, strKey, strDefault, strBuffer, 255, strPath)
   
    ReadKey = strBuffer

End Function



Then to use this function do something such as:

Code:
Private Sub Form_Load()
    Dim strKey As String
    strKey = ReadKey("Default", "Text1")
    Text1.Text = strKey
End Sub


That will read the key 'Text1' inside the section 'Default' in your INI file. If you wish to change the ini path or name change this line in the module code:

Code:
    Dim strPath As String
    strPath = App.Path & "\variables.ini"

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
hackerkts
Expert Cheater
Reputation: 0

Joined: 21 Jan 2006
Posts: 160
Location: Singapore

PostPosted: Wed Jan 09, 2008 8:27 am    Post subject: Reply with quote

OMG! It's short and sweet, thanks!
Actually before I post this thread I did search for it, but I could only found a long winded class script.

Thanks again! Smile

Quote:
Sorry, but you will have to wait 8787 seconds before you can give rep

I own you 1 Surprised

_________________
Quote:
"Give a man a fish and he will eat for a day. Teach a man to fish and he will eat for the rest of his life."

Read it, learn it and love it!
Back to top
View user's profile Send private message
mer0x
Advanced Cheater
Reputation: 0

Joined: 06 Jan 2008
Posts: 63

PostPosted: Wed Jan 09, 2008 3:10 pm    Post subject: Reply with quote

For writing..

Code:

Option Explicit

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpString As Any, ByVal lpFileName As String) As Long


Public Declare Function WriteKey(szSection As String, szKey As String, szString) As String

   Dim szFileName As String
   szFileName = App.Path & "\variables.ini"

   Call WritePrivateProfileString(szSection, szKey, szString, szFileName)

End Function


Example:
Code:

Dim sSection as string
Dim sKey as string

sSection = "test"
sKey = "testkey"
call WriteKey sSection, sKey, 1


Code:

[test]
testkey = 1
Back to top
View user's profile Send private message
hackerkts
Expert Cheater
Reputation: 0

Joined: 21 Jan 2006
Posts: 160
Location: Singapore

PostPosted: Wed Jan 09, 2008 7:59 pm    Post subject: Reply with quote

Thanks for that mer0x, but I don't think I will be too in to writing it to .ini file
I mainly will implement the reading values into flash trainer Very Happy

_________________
Quote:
"Give a man a fish and he will eat for a day. Teach a man to fish and he will eat for the rest of his life."

Read it, learn it and love it!
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