Webcam light still on ever after disconnecting the drivers vb.net 2008 -
i want capture image webcam , found excellent code that, problem after disconnecting webcam drivers webcam light still on. seems webcam still in use. how adjust it?
sendmessage(hhwnd, wm_cap_driver_disconnect, deviceid, 0) destroywindow(hhwnd)
webcam class
public class form1 const wm_cap short = &h400s const wm_cap_driver_connect integer = wm_cap + 10 const wm_cap_driver_disconnect integer = wm_cap + 11 const wm_cap_edit_copy integer = wm_cap + 30 public const wm_cap_get_status integer = wm_cap + 54 public const wm_cap_dlg_videoformat integer = wm_cap + 41 const wm_cap_set_preview integer = wm_cap + 50 const wm_cap_set_previewrate integer = wm_cap + 52 const wm_cap_set_scale integer = wm_cap + 53 const ws_child integer = &h40000000 const ws_visible integer = &h10000000 const swp_nomove short = &h2s const swp_nosize short = 1 const swp_nozorder short = &h4s const hwnd_bottom short = 1 private deviceid integer = 0 ' current device id private hhwnd integer ' handle preview window declare function sendmessage lib "user32" alias "sendmessagea" _ (byval hwnd integer, byval wmsg integer, byval wparam integer, _ byref lparam capstatus) boolean declare function sendmessage lib "user32" alias "sendmessagea" _ (byval hwnd integer, byval wmsg integer, byval wparam boolean, _ byref lparam integer) boolean declare function sendmessage lib "user32" alias "sendmessagea" _ (byval hwnd integer, byval wmsg integer, byval wparam integer, _ byref lparam integer) boolean declare function setwindowpos lib "user32" alias "setwindowpos" (byval hwnd integer, _ byval hwndinsertafter integer, byval x integer, byval y integer, _ byval cx integer, byval cy integer, byval wflags integer) integer declare function destroywindow lib "user32" (byval hndw integer) boolean structure pointapi dim x integer dim y integer end structure private sub loaddevicelist() dim strname string = space(100) dim strver string = space(100) dim breturn boolean dim x short = 0 ' ' load name of avialable devices lstdevices ' ' ' driver name , version ' breturn = capgetdriverdescriptiona(x, strname, 100, strver, 100) ' ' if there device add device name list ' if breturn lstdevices.items.add(strname.trim) x += ctype(1, short) loop until breturn = false end sub private sub openpreviewwindow() ' connect device ' sendmessage(hhwnd, wm_cap_driver_connect, deviceid, 0) end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load loaddevicelist() end sub private sub closepreviewwindow() ' ' disconnect device ' sendmessage(hhwnd, wm_cap_driver_disconnect, deviceid, 0) destroywindow(hhwnd) end sub
start , stop camera
private sub btnstart_click(byval sender system.object, byval e system.eventargs) handles btnstart.click deviceid = lstdevices.selectedindex openpreviewwindow() dim breturn boolean dim s capstatus breturn = sendmessage(hhwnd, wm_cap_get_status, marshal.sizeof(s), s) end sub private sub btnstop_click(byval sender system.object, byval e system.eventargs) handles btnstop.click closepreviewwindow() sendmessage(hhwnd, wm_cap_driver_disconnect, deviceid, 0) end sub end class
Comments
Post a Comment