Click here to Skip to main content
12,626,106 members (34,102 online)
Click here to Skip to main content
Add your own
alternative version

Stats

85K views
756 downloads
39 bookmarked
Posted

Simple Computer Info.

, 3 Jun 2002
Rate this:
Please Sign up or sign in to vote.
Get HostName, Logged On User, SytemRoot, Uptime, and a few more with only a few lines of code.

Sample Image - Environment_Class_small.jpg

Introduction

This is the meat of the program. If you need more, then download the project. It's only 25K.

Public sAppName As String = "Registry Tester"
Public sRegSection As String = "Startup"
Public sXpos As String = "StartPos X"
Public sYpos As String = "StartPos Y"

Public Sub New()
    MyBase.New()
    Dim X, Y As Integer
    X = GetSetting(sAppName, sRegSection, sXpos, CInt(100))
    Y = GetSetting(sAppName, sRegSection, sYpos, CInt(250))
    Me.Location = New Drawing.Point(X, Y)
    Me.StartPosition = FormStartPosition.Manual
    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

End Sub

Private Sub Form1_Closing(ByVal sender As Object, _
  ByVal e As System.ComponentModel.CancelEventArgs) _
  Handles MyBase.Closing
    Dim X, Y As Integer
    X = Me.Location.X
    Y = Me.Location.Y
    SaveSetting(sAppName, sRegSection, sXpos, X)
    SaveSetting(sAppName, sRegSection, sYpos, Y)
End Sub

Private Sub btnDo_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles btnDo.Click
    lblOsVersion.Text = Environment.OSVersion.ToString
    lblUser.Text = Environment.UserName.ToString
    lblRuntime.Text = Environment.Version.ToString
    lblUptime.Text = Mid((Environment.TickCount / 3600000), 1, 5) & " :Hours"
End Sub

Private Sub btnGetRoot_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles btnGetRoot.Click
    lblSystemRoot.Text = _
        Environment.GetFolderPath(Environment.SpecialFolder.System).ToString
End Sub

This project started out from reading "Coding Techniques For Visual Basic .NET". But then I got side tracked on the registry to save app settings. And then I got into the Environment class and all of its glory. I have seen a lot of code written to get uptime and so on, but they were a lot more than this. I hope someone likes it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Bo Hunter
United States United States
My biggest intrests are cars and computers.
I work for one of Nascar's 50 greates drivers
where we build race cars for some people. We
mostly build them for ourselfs to race. I was
very fortunate to have Jack Ingram to take me
under his wing and teach me how to drive LMSC.
So when we are not racing or building new cars
I spend my time learning C++ and the new .Net
languages.

You may also be interested in...

Pro

Comments and Discussions

 
QuestionDownload not work - it download form1.aspx/logon.aspx Pin
SheBi Videography28-Feb-14 0:46
memberSheBi Videography28-Feb-14 0:46 
QuestionComplete System Info Pin
Chandan_Kr13-Jan-06 0:41
memberChandan_Kr13-Jan-06 0:41 
GeneralGetSetting Function Pin
Bo Hunter5-Jun-02 8:36
memberBo Hunter5-Jun-02 8:36 
The GetSetting function will not work the first time because there is no
settings in the registry to get. If you want to use it then comment out all
the code in the Public Sub New() call except for MyBase.New and InitalizeComponet() call. Then run it once too save the settings to the registry. Then uncomment the above and it should work fine. I did'nt think
of that until after the post. The CInt on the end of GetSetting is me trying to convert the default return if GetSetting could not find any setting. But after i deleted the keys in the registry and tryed it. It would not work. So if anyone knows what i am doing wrong please let me know.Confused | :confused:

Bo Hunter
GeneralMy... Pin
arcdemon3-Jun-06 14:17
memberarcdemon3-Jun-06 14:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 4 Jun 2002
Article Copyright 2002 by Bo Hunter
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid