タスクマネージャで気付いたことがある場合は、実行中のタスクを右クリックすると、「最小化」や「最大化」などの多くのオプションがあります。とにかくvbでこれを達成する方法はありますか?
5874 次
1 に答える
5
これがあなたが探しているコードの例です。すべてのアクティブなプロセスをループし、すべてのウィンドウを最小化します。
アプリではProcess.GetProcessesByName
、操作したい特定のウィンドウを見つけるようなものを使用することをお勧めします。
Imports System.Runtime.InteropServices
Module ManipulateWindows
Const SW_HIDE As Integer = 0
Const SW_RESTORE As Integer = 1
Const SW_MINIMIZE As Integer = 2
Const SW_MAXIMIZE As Integer = 3
<DllImport("User32")> _
Private Function ShowWindow(ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
End Function
Public Sub Main()
'iterate through all the open processes.
For Each p As Process In Process.GetProcesses
'Get the Window Handle
Dim hWnd as integer = CType(p.MainWindowHandle, Integer)
'Write out the title of the main window for the process.
System.Console.WriteLine(p.MainWindowTitle)
'Minimize the Window
ShowWindow(hWnd, SW_MINIMIZE)
Next p
End Sub
End Module
于 2011-12-12T22:05:15.663 に答える