• Welcome to Valhalla Legends Archive.
 

Reading from a .ini

Started by QwertyMonster, March 12, 2005, 08:18 AM

Previous topic - Next topic

QwertyMonster

I want my bot to read from my .ini.

I want to create accounts but using the list from a .ini.

I tried


Dim strCompare as string

Acc1.text = right(Strcompare, 1)



And this is my config code


Public Function OpenConfig()
Dim strCompare As String

   
Open App.Path & "\Names.ini" For Output As #1

     Print #1, "Names to make"
    ' Print #1, "Warning: Do it like this: Username-Password"
     Print #1, "Server: "
     Print #1, "CDKEY: "
     Print #1, "1st: Username:Password"

     Close #1

End Function


And on Form_Load i want it to open that file (ive made it do that atm) and then Read the "1st: " text, and create it or whatever, then go to "2nd: " and so on. But i dont know i can make it read them all. I can only get it read ONE  :-\

Help please? :-*

Warrior

Look into these API's


Public 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 GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Archangel


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

Public Function GetFromIni(AppName As String, Key As String, File As String) As String
Dim Default As String, Size As Integer, Value As Long
Dim User As String
User = Space$(128)
Size = Len(User)
Default = ""
Value = GetPrivateProfileString(AppName, Key, Default, User, Size, File)
User = Mid(User, 1, InStr(User, Chr(0)) - 1)
GetFromIni = User
End Function


For calling function:

Config.ini:

[Configuration]
Username=Dan
Password=Owns


Username = GetFromIni("Configuration", "Username", "C:\Config.ini")
Password = GetFromIni("Configuration", "Password", "C:\Config.ini")


[Edit: Grammar Mistakes]
I'm not an Addict.

Blaze

Giving people code doesn't help them really.
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

Archangel

Well, not to hard to make though...
Want me to remove code?
I'm not an Addict.

BaDDBLooD

Quote from: Archangel on March 12, 2005, 10:12 AM
Well, not to hard to make though...
Want me to remove code?

IMO, it would be better to give them the API call and then maybe a short description oh how it works.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

QwertyMonster

Quote from: Archangel on March 12, 2005, 10:12 AM
Well, not to hard to make though...
Want me to remove code?

Well i didnt copy / paste your code so i cant cheat. But if you want remove it, but if you dont, please comment it. It does help people.


Ok, so now ive got the basic jiff of it. But how would i make it stay the same every time i load it up again? Cos it just goes bk to "".

I put it to go to "", but thats the only way i can save it  :-\

Heres my code

Public Function OpenConfig()
Dim strCompare As String

   
Open App.Path & "\Names.ini" For Output As #1

     Print #1, "Names to make"
    ' Print #1, "Warning: Do it like this: Username-Password"
     Print #1, "Server: "
     Print #1, "CDKEY: "
     Print #1, "1st: Username:Password"
     Print #1, "2nd:"
     Print #1, "3rd:"
     Print #1, "4th:"
     Print #1, "5th:"
     Print #1, "6th:"
     Print #1, "7th:"
     Print #1, "8th:"
     Print #1, "9th:"
     Print #1, "10th:"
     Close #1


See i put it to "", only way i can make it save tbh.

Can anybody help?

FrOzeN

Quote from: QwertyMonster on March 12, 2005, 08:18 AMI want to create accounts but using the list from a .ini.

It'd be easier to read lists from a .txt as opposed to an .ini which is better for storing all the details.
~ FrOzeN

UserLoser.

Quote from: FrOzeN on March 12, 2005, 08:29 PM
Quote from: QwertyMonster on March 12, 2005, 08:18 AMI want to create accounts but using the list from a .ini.

It'd be easier to read lists from a .txt as opposed to an .ini which is better for storing all the details.

What makes it easier to read from a file with a certain extension opposed to another?

Blaze

Quote from: Warrior on March 12, 2005, 09:24 PM
the i and n keys are closer than the t and x keys :P



I agree with UserLoser on this one.

You should use the ini Structure if your going to save the file as a .ini
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

FrOzeN

#10
Well to me it sounded like he wanted to create a accounts from a list.
And lists are normally stored in .txt's.

So inside a Accounts.txt or something he would have something like:
Quotename1:*****
name2:*****
name3:*****
name4:*****
name5:*****
etc..

And then a Config.ini have:
Quote[Settings]
CdKey=0000000000000
Product=PXES
Server=useast.battle.net
;etc..

Instead of something like:

Config.ini:
Quote[Settings]
CdKey=0000000000000
Product=PXES
Server=useast.battle.net


    1st=name1:*****
    2nd=name2:*****
    3rd=name3:*****
    4th=name4:*****
    5th=name5:*****
    ;etc..
If Config.ini's are faster for lists why are they never used to store lists then??

[EDIT] Fixed Tags.
~ FrOzeN

Warrior

Why the hell would anyone care about speed (which is barely noticeable) when reading/writing to a file? INI is a more organized way to store information.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

QwertyMonster

Ok, so now basically now i am using a .txt. Now would i read it like this:




Account1 = App.path & "\names.txt", "Names", "Acc1: "




Something along those lines?

R.a.B.B.i.T

This should be in the VB forums and not the BotDev forums.

QwertyMonster

Quote from: rabbit on March 13, 2005, 08:15 AM
This should be in the VB forums and not the BotDev forums.

Yes it should.

But does saying that help my problem? I think some people should go back and read some "News" called "Stay on topic".

Not sounding like a flame, so dont take it like one, but that was a useless Post. :-\