1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| Option Explicit On
Imports System.Threading
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
'............'.
Public Class Form1
<DllImport("user32.dll")>
Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
End Function 'pour positionner la fenêtre de pywin64.exe
<DllImport("user32.dll")>
Shared Function SetWindowText(ByVal hwnd As IntPtr, ByVal windowName As String) As Boolean
End Function 'pour changer le titre de la fenêtre de pywin64.exe
'...........'.
Public Sub StartResolution()
If tTask1 IsNot Nothing Then tTask1 = Nothing
tTask1 = New System.Threading.Thread(AddressOf Task1)
tTask1.IsBackground = True
tTask1.Start()
End Sub
'...........'.
Public Sub Task1()
Try
Using myProcess2 As New Process
myProcess2.StartInfo.FileName = Disk + "\notepad.exe"
If ValidAutoSolution = True Then
myProcess2.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Else
myProcess2.StartInfo.WindowStyle = ProcessWindowStyle.Normal
End If
myProcess2.Start() 'start process exe
Thread.Sleep(50)
'dimensionne la fenêtre cmd sous windows :
SetWindowPos(myProcess2.MainWindowHandle, IntPtr.Zero, 1201, 0, 720, 1000, 0)
End Using
Catch ex As Exception
End Try
End Sub
'.........'.
Private Function KillProcess(ByVal ProcessName As String) As Boolean
Try
Dim svc As Object
Dim sQuery As String
Dim oproc
svc = GetObject("winmgmts:root\cimv2")
sQuery = "select * from win32_process where name='" & ProcessName & "'"
For Each oproc In svc.execquery(sQuery)
Dim v = oproc.Terminate
Next
'svc = Nothing
Catch ex As Exception
End Try
End Function |
Partager