时间: 2021-07-31 作者:daque
declare function findwindow lib "user32" alias "findwindowa" (byval lpclassname as string, byval lpwindowname as string) as long declare function sendmessage lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as long) as long 翻开运用: private sub command1_click() shell "calc.exe", vbnormalfocus end sub 封闭运用: private sub command2_click() dim lpclassname as string dim lpcaption as string dim handle as long const nill = 0& const wm_syscommand = &h112 const sc_close = &hf060& lpclassname = "scicalc" lpcaption = "calculator" 解释:* determine the handle to the calculator window. handle = findwindow(lpclassname$, lpcaption$) 解释:* post a message to calc to end its existence. handle = sendmessage(handle, wm_syscommand, sc_close, nill) end sub