Option Explicit On Option Strict Off Option Compare Text '============================================================================================================= ' ' cApp.vb ' ------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .NET ) ' ' Created On : September 13, 2002 ' Last Update : September 13, 2002 ' ' VB Versions : VB.NET 1.1 (VS.NET 2003) ' ' Requires : The .NET Framework v1.1 ' (Reference System.Windows.Forms.dll) ' ' Description : This module is designed to give you all the functionality available to you via the "App" ' object in Visual Basci 5/6. ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= Imports System.Windows.Forms Class App #Region "Public Methods" Public Shared Function Build() As Integer On Error Resume Next Build = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Build End Function Public Shared Function Comments() As String On Error Resume Next Comments = System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ExecutablePath).Comments End Function Public Shared Function CompanyName() As String On Error Resume Next CompanyName = Application.CompanyName End Function Public Shared Function EXEName() As String On Error Resume Next EXEName = Application.ExecutablePath If EXEName <> "" Then If InStr(EXEName, "\") = 0 Then If InStr(EXEName, "/") <> 0 Then EXEName = EXEName.Substring(InStrRev(EXEName, "/")) End If Else EXEName = EXEName.Substring(InStrRev(EXEName, "\")) End If End If End Function Public Shared Function EXEPath() As String On Error Resume Next EXEPath = Application.ExecutablePath End Function Public Shared Function FileDescription() As String On Error Resume Next FileDescription = System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ExecutablePath).Comments End Function Public Shared Function hInstance() As System.IntPtr On Error Resume Next hInstance = System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetType.Module) End Function Public Shared Function LegalCopyright() As String On Error Resume Next LegalCopyright = System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ExecutablePath).LegalCopyright End Function Public Shared Function LegalTrademarks() As String On Error Resume Next LegalTrademarks = System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ExecutablePath).LegalTrademarks End Function Public Shared Sub LogEvent(ByVal LogBuffer As String, Optional ByVal EventType As System.Diagnostics.EventLogEntryType = EventLogEntryType.Error, Optional ByVal EventID As Integer = 0) On Error Resume Next EventLog.WriteEntry(System.Reflection.Assembly.GetExecutingAssembly.GetName.Name, LogBuffer, EventType, EventID) End Sub Public Shared Function Major() As Integer On Error Resume Next Major = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Major End Function Public Shared Function Minor() As Integer On Error Resume Next Minor = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Minor End Function Public Shared Function Path() As String On Error Resume Next Path = Application.StartupPath End Function Public Shared Function PrevInstance() As Boolean On Error Resume Next Dim objProc As Process Dim objProcs() As Process objProcs = Process.GetProcessesByName(System.Reflection.Assembly.GetExecutingAssembly.GetName.Name, System.Environment.MachineName) For Each objProc In objProcs If objProc.MainModule.FileName = Application.ExecutablePath Then If objProc.Id <> Process.GetCurrentProcess.Id Then PrevInstance = True Exit Function End If End If Next End Function Public Shared Function ProductName() As String On Error Resume Next ProductName = Application.ProductName End Function Public Shared Function Revision() As Integer On Error Resume Next Revision = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.Revision End Function Public Shared Function ThreadID() As Integer On Error Resume Next ThreadID = AppDomain.GetCurrentThreadId End Function Public Shared Function Title() As String On Error Resume Next Title = System.Reflection.Assembly.GetExecutingAssembly.GetName.Name End Function Public Shared Function Version() As String On Error Resume Next Version = Application.ProductVersion End Function #End Region End Class