|
|
#1 (permalink) |
|
Monster Member
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
|
Hey
Well im in the mood of making stuff in VB.NET just to refresh my memory n stuff. i want to ask, what is the method to detect where something is installed? For example i might wanna see where steam is installed and point to its exe without the user having to browse for it. Any info or links wud be great Thanks |
|
|
|
|
|
|
|
#2 (permalink) |
|
Pro Member
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
|
There is no way to simply Query Windows to tell you where something is installed.
You're going to have to search the registry (if the program even has its installation path stored in the registry), or search the entire hard drive for "Steam". chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots. - |
|
|
|
|
|
#3 (permalink) |
|
Monster Member
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
|
What kind of process do you think Xfire or The Arena use when they scan for games? Do they scan for an exe which matches somethign against their database and if its found they add it?
Ok then lets say i get the user to point to steam, how do i make the program remember and recall that? I was thinking of outputting to a config file which is fine but just reading back in to the application im not sure how to do. |
|
|
|
|
|
#4 (permalink) |
|
Pro Member
Join Date: May 2006
Location: Sydney, Australia
Posts: 6,539
Rep Power: 9
|
What Chem said..
HKEY_CURRENT_USER\Software\Valve\Steam - SteamPath (REG_SZ) Almost all programs which are installed will have their paths stored in the registry, but it's up to you in knowing what and where they are. So yes, programs like xfire have a database of games with methods to check whether they are installed (most of which rely on the registry).
__________________
OM NOM NOM |
|
|
|
|
|
#5 (permalink) |
|
Pro Member
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
|
They would scan for known developers. Obviously, The Arena and XFire cannot tell a game apart from Microsoft Word.. so they would be checked against a list of available developers (Valve, iD Software, Gearbox, Activision, etc).
As for storing it.. it depends on how many developers/games you think you'll end up having? Storing them in a text file would be fine for say.. 50+, any more than that and you'd probably want to look into a database. As for reading it, in .NET, reading and writing are so similar its hard to tell them apart. The only line you'll need to change is the read (instead of the write), for example: Code:
' Reading
Dim fs As New FileStream("C:\test.txt", FileMode.Open, FileAccess.Read)
Dim fr As New StreamReader(fs)
While Not (fr.EOF)
MessageBox.Show(fr.ReadLine())
Wend
Code:
' Writing
Dim fs As New FileStream("C:\test.txt", FileMode.Create, FileAccess.Write)
Dim fw As New StreamWriter(fs)
fw.WriteLine("Activision")
__________________
There are no stupid questions... but there are alot of inquisitive idiots. - |
|
|
|
|
|
#6 (permalink) |
|
Monster Member
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
|
OK well ive been working on my program abit more. Ive achieved the writing and reading so far but ive stumbled across somethign i dont recall doing before. In my program i currently have 2 forms. One form is the main form and the other form is a form which will run only if the configuration file is not created. The startup form at the moment i have set it to the configuration form.
I have written this piece of code to determine if the config file has been created Code:
If IO.File.Exists("config.ini") Then
frmMain.Show()
me.dispose <<<< This is wrong so what should i do?
Else
MsgBox("This is the first time running. The program will load the setup process...", , "First Run - Setup")
End If
Any help would be thanks oh and chem thanks for the read write stuff. Useful |
|
|
|
|
|
#7 (permalink) |
|
Pro Member
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
|
The visible property of a form is boolean.. you need to set it:
Code:
Me.Visible = False ' Me.Visible = True As for your problem: Set the startup form to the config form. That way, when the config form loads (first), you check if the config exists, if it does, you can just Me.Visible = False, and show the "main" form. You can set the startup form in the project properties. If you do the above, use this to exit your program afterwards: Code:
Application.Exit(0)
__________________
There are no stupid questions... but there are alot of inquisitive idiots. - |
|
|
|
|
|
#8 (permalink) |
|
Monster Member
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
|
chem that didnt work because you cant change the visible property of the startup form through its form load, as i was reading. So i found a work around by creating a sub main and that will handle the forms which are being displayed.
This is the code for my sub main Code:
Module startupMain
Sub Main()
Dim mainFrm As New frmMain()
Dim configFrm As New config()
If IO.File.Exists("config.ini") Then
mainFrm.ShowDialog()
Else
MsgBox("This is the first time running. The program will load the setup process...", , "First Run - Setup")
configFrm.ShowDialog()
mainFrm.ShowDialog()
End If
End Sub
End Module
|
|
|
|
|
|
#10 (permalink) |
|
Monster Member
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
|
Ok, ive got this thing going. Now for reading from the text file. This is what it look like
Code:
[Steam Games]
steam.exe
70, = Half-Life {Installed}
10, = Counter-Strike {Installed}
30, = Day of Defeat {Installed}
80, = Condition Zero {Installed}
220, = Half-Life 2 {Installed}
240, = Counter-Strike: Source {Installed}
300, = Day of Defeat: Source {Installed}
4000, = Gary's Mod {Installed}
380, = Half-Life 2 Episode 1 {Installed}
Any ideas? chem? lol |
|
|
|
|
|
#11 (permalink) |
|
Pro Member
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
|
I would read the file in line by line (filestream.ReadLine()), and on each line do something like this: (Note: I don't actually program in VB.NET, so this is a rough translation from C#)
Code:
Dim pos As Integer ' position of the comma
Dim line As String ' the line being read in
line = filestream.ReadLine()
pos = line.IndexOf(",")
MessageBox.Show(line.Substring(0, pos))
chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots. - |
|
|
|






