Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Almighty on December 29, 2005, 12:46 AM

Title: I need help creating Access for my bot
Post by: Almighty on December 29, 2005, 12:46 AM
I wanna make access load and read from Access.ini or Users.txt file but i really dont know where to start jus need a lil a help
Title: Re: I need help creating Access for my bot
Post by: Joe[x86] on December 29, 2005, 09:58 AM
I'm not totally evil, so here, I'll give you a place to start.

Kernel32.dll:

GetPrivateProfileStringA {
    LPCSTR lpApplicationName,
    LPCSTR lpKeyName,
    LPCSTR lpDefault,
    LPCSTR lpReturnedString,
    int nSize,
    LPCSTR lpFileName
};
int WritePrivateProfileStringA {
    LPCSTR lpApplicationName,
    LPCSTR lpKeyName,
    LPCSTR lpString,
    LPCSTR lpFileName
};
Title: Re: I need help creating Access for my bot
Post by: Ryan Marcus on December 31, 2005, 09:46 PM
Uh.. either I'm dumb or your code makes no sence for writting and reading files...


Here is some REALbasic code that simply writes out a text file and looping through an array of users, pretty basic stuff.. You should have learned this before you came close to being able to write a bot.. You should be able to adapt it to VB easily.


dim textout as textoutputstream
dim f as folderitem
dim i as integer

f = GetFolderItem("users.txt")
textout = f.CreateTextFile

while i<>UBound(users) + 1
textout.writeline(users(i).someprop)
textout.writeline(users(i).someprop)
textout.writeline(users(i).someprop)
i =i + 1
wend


Hope that helps.
Title: Re: I need help creating Access for my bot
Post by: MyndFyre on January 01, 2006, 04:43 AM
Quote from: Ryan Marcus on December 31, 2005, 09:46 PM
Uh.. either I'm dumb or your code makes no sence for writting and reading files...

The information that Joe provided are exports from Windows' kernel32.dll (and kernel32.lib) for reading and writing .ini files.
Title: Re: I need help creating Access for my bot
Post by: Joe[x86] on January 01, 2006, 05:36 AM
It may be worth noting that Visual Basic has no TextOutputStream. Asuming you were going to do it Ryan's way, which I don't recomment (the Kernel32 calls are more efficient, and easier), then you'd use the following code:

Dim FileHandle&: FileHandle = #FreeFile
Open App.Path & "\config.ini" For Append as FileHandle '// Note: You may want to change config.ini to whatever setting file you're using.
   Print #1, "SettingName=SettingValue"
Close FileHandle


EDIT -
If for some reason you wanted to write UTF-8 widestrings, define the DLL calls as GetPrivateProfileStringW and WritePrivateProfileStringW.
Title: Re: I need help creating Access for my bot
Post by: MyndFyre on January 01, 2006, 05:49 AM
Quote from: Joe on January 01, 2006, 05:36 AM
It may be worth noting that Visual Basic has no TextOutputStream. Asuming you were going to do it Ryan's way, which I don't recomment (the Kernel32 calls are more efficient, and easier), then you'd use the following code:

Dim FileHandle&: FileHandle = #FreeFile
Open App.Path & "\config.ini" For Append as FileHandle '// Note: You may want to change config.ini to whatever setting file you're using.
   Print #1, "SettingName=SettingValue"
Close FileHandle


EDIT -
If for some reason you wanted to write UTF-8 widestrings, define the DLL calls as GetPrivateProfileStringW and WritePrivateProfileStringW.

Why are you posting rather pointless nonsense trying to criticize Ryan?  The original poster never said ANYTHING about what he's writing in.  For all you know he might be in RB; he certainly never said he was using VB.

Of course, the quality of the original post made everyone ASSUME it was a VB luser, but that's another debate.
Title: Re: I need help creating Access for my bot
Post by: Warrior on January 01, 2006, 06:41 AM
haha @ luser.
Title: Re: I need help creating Access for my bot
Post by: Ryan Marcus on January 01, 2006, 10:32 AM
Quote
Why are you posting rather pointless nonsense trying to criticize Ryan?  The original poster never said ANYTHING about what he's writing in.  For all you know he might be in RB; he certainly never said he was using VB.
Its cool. I know Joe pretty well from x86. I don't think he met any offense, but he could have worded that a bit better.

Quote
Of course, the quality of the original post made everyone ASSUME it was a VB luser, but that's another debate.

I would'nt even call it a debate... If somebody can write a bot before they can write out to a file and read one in, they are using CSB (and thus have no idea what they are doing), or they are some crazy raised from birth by evil anti-blizzard nazi's who want to conquer all of battle.net with an ultimate flood bot... The later does not seem too promising, but it sounds cooler. ;)


I posted the RB because I assumed it could be easily converted to VB. Apartly, thats something that can't.
Title: Re: I need help creating Access for my bot
Post by: FrOzeN on January 03, 2006, 03:03 AM
Quote from: Joe on January 01, 2006, 05:36 AM
It may be worth noting that Visual Basic has no TextOutputStream.
It may be worth noting that Ryan said that was for REALbasic.

In Visual Basic 6 his code would look like:
Dim oFSO As New Scripting.FileSystemObject
Dim oFile As Scripting.File
Dim i As Integer

Set oFile = oFSO.OpenTextFile(App.Path & "\users.txt", ForWriting, True)

While i <> UBound(users) + 1
    oFile.WriteLine users(i).someprop
    oFile.WriteLine users(i).someprop
    oFile.WriteLine users(i).someprop
    i = i + 1
Wend

Set oFile = Nothing