Imports System.Xml
Imports System.IO
Imports System.Collections.Generic
Public Class Form1
Dim myprocess As New System.Diagnostics.Process()
Dim xDoc As New XmlDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function FgetAlldetailProcess(ByVal outTextAllDetailProcess As String) As String
For Each Me.myprocess In System.Diagnostics.Process.GetProcesses()
If myprocess.MainWindowTitle = "" Then
Else
outTextAllDetailProcess &= myprocess.Id & ControlChars.Tab _
& myprocess.MainWindowTitle & ControlChars.Tab _
& Environment.UserName & vbCrLf
End If
Next
Return outTextAllDetailProcess
End Function
Function createXML() As String
Dim p As String = ""
p = FgetAlldetailProcess(p)
Dim ArrPid() As String
ArrPid = p.Split("")
For i = 0 To UBound(ArrPid)
TextBox1.Text &= ArrPid(i)
Next
Dim data As XElement = _
<LogApp>
<%= From f In ArrPid _
Let c = f.Split(New String() {ControlChars.Tab}, StringSplitOptions.RemoveEmptyEntries) _
Select _
<Data>
<Pid><%= (c(0)) %></Pid>
<Pname><%= (c(1)) %></Pname>
<user><%= (c(2)) %></user>
</Data> %>
</LogApp>
data.Save("C:\logApp.xml")
Return xDoc.OuterXml
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
createXML()
End Sub
End Class