Old 16-07-2007   #1 (permalink)
Monster Member
 
SargeRX8's Avatar
 
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
Default VB.NET - Program Directories

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
__________________

Click the sig to watch my Rambo Video

HuggyCHEA[2f][2sxc]: im a gentleman gee
HuggyCHEA[2f][2sxc]: but get me drunk broo, ill grab your tits
SargeRX8 is offline   Reply With Quote
Old 16-07-2007   #2 (permalink)
Pro Member
 
chemicalNova's Avatar
 
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
Default

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.
-
chemicalNova is offline   Reply With Quote
Old 16-07-2007   #3 (permalink)
Monster Member
 
SargeRX8's Avatar
 
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
Default

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.
__________________

Click the sig to watch my Rambo Video

HuggyCHEA[2f][2sxc]: im a gentleman gee
HuggyCHEA[2f][2sxc]: but get me drunk broo, ill grab your tits
SargeRX8 is offline   Reply With Quote
Old 16-07-2007   #4 (permalink)
Pro Member
 
nuk3's Avatar
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 6,539
Rep Power: 9
Default

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
nuk3 is offline   Reply With Quote
Old 16-07-2007   #5 (permalink)
Pro Member
 
chemicalNova's Avatar
 
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
Default

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")
chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots.
-
chemicalNova is offline   Reply With Quote
Old 17-07-2007   #6 (permalink)
Monster Member
 
SargeRX8's Avatar
 
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
Default

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
As you can see im using me.dispose to kill the config setup form, but in doing so im closing the main form hence ending the program. Does anyone know of a solution where i can check if the config exists and if it does DONT show the config form and go straight to the main program? Me.hide and me.visible both do nothing for some odd reason.

Any help would be thanks

oh and chem thanks for the read write stuff. Useful
__________________

Click the sig to watch my Rambo Video

HuggyCHEA[2f][2sxc]: im a gentleman gee
HuggyCHEA[2f][2sxc]: but get me drunk broo, ill grab your tits
SargeRX8 is offline   Reply With Quote
Old 17-07-2007   #7 (permalink)
Pro Member
 
chemicalNova's Avatar
 
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
Default

The visible property of a form is boolean.. you need to set it:
Code:
Me.Visible = False
'
Me.Visible = True
etc..

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)
chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots.
-
chemicalNova is offline   Reply With Quote
Old 17-07-2007   #8 (permalink)
Monster Member
 
SargeRX8's Avatar
 
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
Default

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
Thanks bud. +rep for your helpfulness
__________________

Click the sig to watch my Rambo Video

HuggyCHEA[2f][2sxc]: im a gentleman gee
HuggyCHEA[2f][2sxc]: but get me drunk broo, ill grab your tits
SargeRX8 is offline   Reply With Quote
Old 17-07-2007   #9 (permalink)
Pro Member
 
chemicalNova's Avatar
 
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
Default

Thats odd.. you can with C#.. I've done it on a few occasions

Oh well, glad you found your answer

chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots.
-
chemicalNova is offline   Reply With Quote
Old 17-07-2007   #10 (permalink)
Monster Member
 
SargeRX8's Avatar
 
Join Date: Nov 2006
Location: Merrylands 2160
Age: 21
Posts: 3,687
Rep Power: 6
Default

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}
These are all the lines that are in the text file. How do i go about reading just the integer parts of each line to a variable? like i want to go through a loop, read in 70, do the process then back to the top, read in 10, do the process etc. Ive looked at delimiters n stuff but dunno.

Any ideas? chem? lol
__________________

Click the sig to watch my Rambo Video

HuggyCHEA[2f][2sxc]: im a gentleman gee
HuggyCHEA[2f][2sxc]: but get me drunk broo, ill grab your tits
SargeRX8 is offline   Reply With Quote
Old 19-07-2007   #11 (permalink)
Pro Member
 
chemicalNova's Avatar
 
Join Date: Jun 2006
Age: 19
Posts: 5,593
Rep Power: 8
Default

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))
You'll have to use the TryParse functions to convert the string to an integer (if thats what you desire).

chem
__________________
There are no stupid questions... but there are alot of inquisitive idiots.
-
chemicalNova is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +10. The time now is 07:08 AM.


Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0