Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetProcessById() on another server
Message
De
02/02/2015 10:52:57
 
 
À
02/02/2015 10:37:52
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614754
Message ID:
01614755
Vues:
24
This class takes care of the 2nd parameter supported by GetProcessById():
Public Class OS

    Public cMessage As String = ""
    Public cServer As String = ""
    Public lRunning As Boolean = False
    Public nProcessID As Integer = 0
    Private cYouNeedToDefineTheProcessID As String = ""
    Private nLanguage As Integer = 1
    Private oApp As App = Nothing
    Private oProcess As LXProcess = Nothing

    ' This is when we access the data provider in desktop and Web service mode
    Sub New(ByVal toApplication As App)
        oApp = toApplication
        nLanguage = oApp.nLanguage
        Init()
    End Sub

    ' This is when we access the data provider in a Web mode
    Public Sub New(ByVal toProcess As LXProcess)
        oProcess = toProcess
        oApp = oProcess.oApp
        nLanguage = oProcess.nLanguage
        Init()
    End Sub


    ' Initialization
    Private Function Init() As Boolean

        ' Based on the language
        Select Case nLanguage

            ' English
            Case 1
                cYouNeedToDefineTheProcessID = "You need to define the nProcessID property."

                ' French
            Case 2
                cYouNeedToDefineTheProcessID = "Vous devez définir la propriété nProcessID."

                ' Spanish
            Case 3
                cYouNeedToDefineTheProcessID = "You need to define the nProcessID property."

                ' Portuguese
            Case 4
                cYouNeedToDefineTheProcessID = "You need to define the nProcessID property."

        End Select

        Return True
    End Function

    ' See if a process ID is running
    Public Function IsProcessRunning() As Boolean
        Dim lcServer As String = ""
        Dim llSuccess As Boolean = False
        Dim loProcess As Process = Nothing

        ' Reset everything
        cMessage = ""
        lRunning = False

        ' Initialization
        lcServer = Trim(cServer)

        ' If we have not defined the process ID
        If nProcessID = 0 Then
            cMessage = cYouNeedToDefineTheProcessID
            Return False
        End If

        ' Try to get an object
        Try

            ' If we have a server
            If lcServer.Length > 0 Then
                loProcess = Process.GetProcessById(nProcessID, lcServer)
            Else
                loProcess = Process.GetProcessById(nProcessID)
            End If

            llSuccess = True
        Catch loError As Exception
            cMessage = loError.Message
            Return False
        End Try

        ' If the process is running
        If Not IsNothing(loProcess) Then
            lRunning = True
        End If

        ' Reset everything
        cServer = ""
        nProcessID = 0

        Return llSuccess
    End Function

End Class
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform