VB.Net/Windows System/Environment Setting — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:44, 26 мая 2010

Adding Favorites

  
Public Class MainClass
    Public Shared Sub Main()
        CreateShortcut("Demo", "http://www.a.net/")
    End Sub
    Public Shared Sub CreateShortcut(ByVal Title As String, ByVal URL As String)
        Dim strFavoriteFolder As String
        strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
        Dim objWriter As System.IO.StreamWriter = System.IO.File.CreateText(strFavoriteFolder & "\" & Title & ".url")
        objWriter.WriteLine("[InternetShortcut]")
        objWriter.WriteLine("URL=" & URL)
        objWriter.Close()
    End Sub
End Class


Display System Stack Trace

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("StackTrace:         " & System.Environment.StackTrace )
   End Sub 
End Class


Get Environment Variable by Name

 
Imports System
Public Class MainClass
   Shared Sub Main()
         Console.WriteLine(Environ("USERNAME"))
   End Sub 
End Class


Get Machine Name

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("MachineName:        " & System.Environment.MachineName)
   End Sub 
End Class


Get .Net Runtime Environment Version Number

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("Version:            " & System.Environment.Version.ToString)
   End Sub 
End Class


Get OS Version

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("OSVersion:          " & System.Environment.OSVersion.VersionString)
   End Sub 
End Class


Get Processor Count

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("ProcessorCount:     " & System.Environment.ProcessorCount)
   End Sub 
End Class


Get Sysstem Directory

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("SystemDirectory:    " & System.Environment.SystemDirectory)
   End Sub 
End Class


Get System Exit Code

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("ExitCode:           " & System.Environment.ExitCode )
   End Sub 
End Class


Get System New Line Code

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("NewLine:            " & System.Environment.NewLine)
   End Sub 
End Class


Get Tick Count

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("TickCount:          " & System.Environment.TickCount)
   End Sub 
End Class


Get Working Set

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("WorkingSet:         " & System.Environment.WorkingSet)
   End Sub 
End Class


Has Shutdown Started

 
Imports System

Public Class MainClass
   Shared Sub Main()
        Console.WriteLine("HasShutdownStarted: " & System.Environment.HasShutdownStarted )
   End Sub 
End Class


List your environment Setting

 
Imports System
Public Class MainClass
   Shared Sub Main()
        For i As Integer = 1 To 255
            If Environ(i).Length = 0 Then Exit For
            Console.WriteLine( Environ(i) )
        Next i
   End Sub 
End Class