'你要關閉什麼程序
'就寫
'call taskkill("程序名.exe")
'注意大小寫啊
private declare function createtoolhelp32snapshot lib "kernel32" (byval dwflags as long, byval th32processid as long) as long
private declare function process32first lib "kernel32" (byval hsnapshot as long, lppe as processentry32) as long
private declare function process32next lib "kernel32" (byval hsnapshot as long, lppe as processentry32) as long
private declare function closehandle lib "kernel32" (byval hobject as long) as long
private type processentry32
dwsize as long
cntusage as long
th32processid as long
th32defaultheapid as long
th32moduleid as long
cntthreads as long
th32parentprocessid as long
pcpriclassbase as long
dwflags as long
szexefile as string * 1024
end type
const th32cs_snapheaplist = &h1
const th32cs_snapthread = &h4
const th32cs_snapmodule = &h8
const th32cs_inherit = &h80000000
dim pid as long
dim pname as string
'-------------結束程序通用函式 注意程序名要區分大小寫
private sub taskkill(byval taskname as string)
dim my as processentry32
dim l as long
dim l1 as long
dim flag as boolean
dim mname as string
dim i as integer
if l then
my.dwsize = 1060
if (process32first(l, my)) then '遍歷第乙個程序
do i = instr(1, my.szexefile, chr$(0))
mname = lcase$(left$(my.szexefile, i - 1))
if mname = lcase$(taskname) then
pid = my.th32processid
pname = mname
dim mprocid as long
mprocid = openprocess(1&, -1&, pid)
terminateprocess mprocid, 0&
flag = true
exit function
else
flag = false
end if
loop until (process32next(l, my) < 1) '遍歷所有程序知道返回值為false
end if
l1 = closehandle(l)
end if
end sub
private sub command1_click()
call taskkill("notepad.exe")
'這個是關閉記事本程序的
end sub
一段小程式 3
做個題目練練手,不然c語言都忘記了。設計一程式實現功能,處理字串a,處理規則是 只要b字串裡面有的字母,不分大小寫,一律從a字串中刪掉。1 請畫出此演算法的流程圖 2 請用c語言編寫對應的 include stdio.h include stdlib.h include string.h defin...
華為的面試題,要求8分鐘寫出一段程式
華為的面試題,要求8分鐘寫出一段程式 有兩個陣列a,b,大小都為n,陣列元素的值任意,無序 要求 通過交換a,b中的元素,使陣列a元素的和與陣列b元素的和之間的差最小 include using namespace std define n 5 int a int b void swap int a...
一段程式看懂位元幣原理
自從位元幣火起來以後,網上對位元幣的解釋可謂汗牛充棟,紛繁複雜。但對於程式設計師來說,最直接的方式莫過於直接看程式 了。嫌位元幣 龐雜沒關係,我找到一段簡明扼要的 用來理解位元幣再好不過了。以下這段程式 知乎上wu hao的回答。function mine function sendbtc amou...