⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 environment.vb

📁 Pocket Image Editor v0.1源码(.NET源码)
💻 VB
字号:
'==========================================================================================
'
'		OpenNETCF.Environment
'		Copyright (c) 2003, OpenNETCF.org
'
'		This library is free software; you can redistribute it and/or modify it under 
'		the terms of the OpenNETCF.org Shared Source License.
'
'		This library is distributed in the hope that it will be useful, but 
'		WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
'		FITNESS FOR A PARTICULAR PURPOSE. See the OpenNETCF.org Shared Source License 
'		for more details.
'
'		You should have received a copy of the OpenNETCF.org Shared Source License 
'		along with this library; if not, email licensing@opennetcf.org to request a copy.
'
'		If you wish to contact the OpenNETCF Advisory Board to discuss licensing, please 
'		email licensing@opennetcf.org.
'
'		For general enquiries, email enquiries@opennetcf.org or visit our website at:
'		http://www.opennetcf.org
'
'==========================================================================================
Imports System
Imports System.Text
Imports System.Runtime.InteropServices

Namespace OpenNETCF

    '/ <summary>
    '/ Extends the functionality of <see cref="T:System.Environment"/>
    '/ </summary>
    '/ <seealso cref="T:System.Environment">System.Environment Class</seealso>
    Public Class Environment

        'maximum supported length of a file path
        Private Const MaxPath As Integer = 260


        Private Sub New()
        End Sub 'New 
#Region "New Line"

        '/ <summary>
        '/ Gets the newline string defined for this environment.
        '/ </summary>
        '/ <value>A string containing "\r\n".</value>
        '/ <remarks>The property value is a constant customized specifically for the current platform.
        '/ This value is automatically appended to text when using WriteLine methods, such as <see cref="M:T:System.Console.WriteLine(System.String)">Console.WriteLine</see>.</remarks>
        '/ <seealso cref="P:System.Environment.NewLine">System.Environment.NewLine Property</seealso>
        Public Shared ReadOnly Property NewLine() As String
            Get
                Return ControlChars.Cr + ControlChars.Lf
            End Get
        End Property
#End Region

#Region "System Directory"

        '/ <summary>
        '/ Gets the fully qualified path of the system directory.
        '/ </summary>
        '/ <value>A string containing a directory path.</value>
        '/ <remarks>An example of the value returned is the string "\Windows".</remarks>
        '/ <seealso cref="P:System.Environment.SystemDirectory">System.Environment.SystemDirectory Property</seealso>
        Public Shared ReadOnly Property SystemDirectory() As String
            Get
                Return "\Windows"
            End Get
        End Property
#End Region

#Region "Get Folder Path"

        '/ <summary>
        '/ Gets the path to the system special folder identified by the specified enumeration.
        '/ </summary>
        '/ <param name="folder">An enumerated constant that identifies a system special folder.</param>
        '/ <returns>The path to the specified system special folder, if that folder physically exists on your computer; otherwise, the empty string ("").  A folder will not physically exist if the operating system did not create it, the existing folder was deleted, or the folder is a virtual directory, such as My Computer, which does not correspond to a physical path.</returns>
        '/ <seealso cref="M:System.Environment.GetFolderPath(System.Environment.SpecialFolder)">System.Environment.GetFolderPath Method</seealso>
        Public Shared Function GetFolderPath(ByVal folder As SpecialFolder) As String
            Dim path As New StringBuilder(MaxPath)

            If Not Convert.ToBoolean(SHGetSpecialFolderPath(IntPtr.Zero, path, Fix(folder), 0)) Then
                Throw New Exception("Cannot get folder path!")
            End If

            Return path.ToString()
        End Function 'GetFolderPath


        <DllImport("coredll", EntryPoint:="SHGetSpecialFolderPath", SetLastError:=False)> _
        Friend Shared Function SHGetSpecialFolderPath(ByVal hwndOwner As IntPtr, ByVal lpszPath As StringBuilder, ByVal nFolder As Integer, ByVal fCreate As Integer) As Integer
        End Function

#End Region

#Region "Special Folder"

        '/ <summary>
        '/ Specifies enumerated constants used to retrieve directory paths to system special folders.
        '/ </summary>
        '/ <remarks>Not all platforms support all of these constants.</remarks>
        '/ <seealso cref="T:System.Environment.SpecialFolder">System.Environment.SpecialFolder Enumeration</seealso>
        Public Enum SpecialFolder
            '/ <summary>
            '/ "\"
            '/ </summary>
            VirtualRoot = &H0
            '/ <summary>
            '/ The directory that contains the user's program groups.
            '/ </summary>
            Programs = &H2
            '/ <summary>
            '/ control panel icons
            '/ </summary>
            Controls = &H3
            '/ <summary>
            '/ printers folder
            '/ </summary>
            Printers = &H4
            '/ <summary>
            '/ The directory that serves as a common repository for documents. (Not supported in Pocket PC and Pocket PC 2002 - "\My Documents").
            '/ </summary>
            Personal = &H5
            '/ <summary>
            '/ The directory that serves as a common repository for the user's favorite items.
            '/ </summary>
            Favorites = &H6
            '/ <summary>
            '/ The directory that corresponds to the user's Startup program group.   The system starts these programs whenever a user starts Windows CE.
            '/ </summary>
            Startup = &H7
            '/ <summary>
            '/ The directory that contains the user's most recently used documents.
            '/ </summary>
            Recent = &H8
            '/ <summary>
            '/ The directory that contains the Send To menu items.
            '/ </summary>
            SendTo = &H9
            '/ <summary>
            '/ Recycle bin.
            '/ </summary>
            RecycleBin = &HA
            '/ <summary>
            '/ The directory that contains the Start menu items.
            '/ </summary>
            StartMenu = &HB
            '/ <summary>
            '/ The directory used to physically store file objects on the desktop.   Do not confuse this directory with the desktop folder itself, which is a virtual folder.
            '/ </summary>
            DesktopDirectory = &H10
            '/ <summary>
            '/ The "My Computer" folder.
            '/ </summary>
            MyComputer = &H11
            '/ <summary>
            '/ Network Neighbourhood
            '/ </summary>
            NetNeighborhood = &H12
            '/ <summary>
            '/ "\Windows\Fonts"
            '/ </summary>
            Fonts = &H14
        End Enum 'SpecialFolder
#End Region
    End Class 'Environment 
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -