'User32.dll API, FindWindowA去尋找開啟視窗
Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String,
ByVal lpWindowName As String) As Integer
'控制視窗狀態
Declare Function ShowWindow Lib "User32" (ByVal hWnd As Integer,
ByVal nCmdShow As Integer) As Integer
'Lock Window
Declare Function EnableWindow Lib "user32" Alias "EnableWindow" (ByVal hwnd As Integer, ByVal fEnable As Boolean) As Integer
'目前還不清楚為什麼無法隱藏
工作管理員的應用程式,已經成功影藏
但是介面還是可以看到
可能要再隱藏子視窗之類的
目前先透過EnableWindow
將視窗鎖住,無法操控視窗介面,無法關閉
再來就看啟動的時候應該怎麼載入
或是透過啟動主程式之後再啟動Scand介面
=================================================================
================================================================
hwnd | 視窗的名稱 (不知道這樣解釋對不對) |
lpOperation | 進行的操作,如"open","print","explore"分別對應 "開啟","列印","瀏覽", 也可以為空(""),此時表示進行預設的操作。 |
lpFile | 要操作的文件。 |
lpParameters | 如果lpFile指定的是一個可執行檔則表示參數 |
lpDirectory | 操作進行的目錄 |
nShowCmd | 新的應用程式的運行方式。其可用的值如下: |
SW_HIDE | 隱藏 |
SW_MAXIMIZE | 最大化 |
SW_MINIMIZE | 最小化,並把Z order順序在此視窗之後(即視窗下一層)的視窗啟動 |
SW_RESTORE | 啟動視窗並還原為初始化大小 |
SW_SHOW | 以當前大小和狀態啟動視窗 |
SW_SHOWDEFAULT | 以預設方式運行 |
SW_SHOWMAXIMIZED | 啟動視窗並最大化 |
SW_SHOWMINIMIZED | 啟動視窗並最小化 |
SW_SHOWMINNOACTIVE | 最小化但不改變當前啟動的視窗 |
SW_SHOWNA | 以當前狀態顯示視窗但不改變當前啟動的視窗 |
SW_SHOWNOACTIVATE | 以初始化大小顯示視窗但不改變當前啟動的視窗 |
SW_SHOWNORMAL | 啟動並顯示視窗,如果是最大(小)化,視窗將會還原。第一次運行程式 時應該使用這個值 |
============================================================
[VB.NET]使用WinAPI的FindWindow判斷程式是否運行
================================================
[C#] 使用 Win32 API 來進行控制其他程式視窗行為表現
延续如何隐藏"开始"菜单的话题
隐藏Window工作列(Taskbar)的做法,跟隐藏"开始"菜单相同,所以一同提出
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const SWPHIDEWINDOW = &H80 '显示视窗
Public Const SWPSHOWWINDOW = &H40 '隐藏视窗
'---------------------------------------------------------------------------------
Sub HideTaskbar()
Dim hWndT As Long
hWnd = FindWindow("shell_traywnd", vbNullString)
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWPHIDEWINDOW
End Sub
'----------------------------------------------------------------------------------
Sub ShowTaskbar()
Dim hWnd As Long
hWnd = FindWindow("shell_traywnd", vbNullString)
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWPSHOWWINDOW
End Sub
隐藏Window工作列(Taskbar)的做法,跟隐藏"开始"菜单相同,所以一同提出
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const SWPHIDEWINDOW = &H80 '显示视窗
Public Const SWPSHOWWINDOW = &H40 '隐藏视窗
'---------------------------------------------------------------------------------
Sub HideTaskbar()
Dim hWndT As Long
hWnd = FindWindow("shell_traywnd", vbNullString)
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWPHIDEWINDOW
End Sub
'----------------------------------------------------------------------------------
Sub ShowTaskbar()
Dim hWnd As Long
hWnd = FindWindow("shell_traywnd", vbNullString)
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWPSHOWWINDOW
End Sub
================================================================
CWnd::SetWindowPos
PInvoke 簽章的呼叫慣例及參數與目標 Unmanaged 簽章是否相符
http://social.msdn.microsoft.com/Forums/zh-HK/233/thread/f7089c7b-219f-41f4-9ac1-4ca724a39799
Dim Handle As IntPtr
'找開啟視窗程式名稱,傳回integer
Handle = FindWindow(0&, WindowName) = > 簽章不相符
FindWindow( ClassName參數, 視窗標題名稱WindowName參數)
= > FindWindow( Nothing, WindowName)
這樣就可以了
剛剛突然一想 他說我沒宣告 我就宣告一個NULL
private:
/// <summary>
/// 設計工具所需的變數。
String^ NULL;
/// </summary>
結果就可以了@@
到此結案!!
Dim Handle As IntPtr
'找開啟視窗程式名稱,傳回integer
Handle = FindWindow(0&, WindowName) = > 簽章不相符
FindWindow( ClassName參數, 視窗標題名稱WindowName參數)
= > FindWindow( Nothing, WindowName)
這樣就可以了
剛剛突然一想 他說我沒宣告 我就宣告一個NULL
private:
/// <summary>
/// 設計工具所需的變數。
String^ NULL;
/// </summary>
結果就可以了@@
到此結案!!
沒有留言:
張貼留言