5,692,513 members and growing! (14,878 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Intermediate

Accessing WebCam in Visual Basic 6

By dixanta

Accessing WebCam in Visual Basic 6
VBScript, VB 6, VB, .NET, Windows, NT4, Win2K, WinXP, Win2003VS6, Visual Studio, Dev

Posted: 11 Mar 2006
Updated: 11 Mar 2006
Views: 55,546
Bookmarked: 15 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
7 votes for this Article.
Popularity: 1.97 Rating: 2.33 out of 5
2 votes, 28.6%
1
1 vote, 14.3%
2
1 vote, 14.3%
3
0 votes, 0.0%
4
3 votes, 42.9%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

This is a simple program and can be use to access webcam from the visual basic 6.

This program checks whether webcam is available or not. If not available simple gives

a message otherwise capture from the webcam and displays in picture box.

This program has 3 diffrent functionality.

 

  1. Capture from the webcam
  2. Close the webcam
  3. Format the video

Source Code 


'This program check whether webcam is available or not
'
if available then capture and displays in picture box

'Created by Dixanta Bahadur Shrestha
'
Created Date: 12-March-2006

'Programmer does not garuntees if not functions well

Global Const ws_child As Long = &H40000000
Global Const ws_visible As Long = &H10000000

Global Const WM_USER = 1024
Global Const wm_cap_driver_connect = WM_USER + 10
Global Const wm_cap_set_preview = WM_USER + 50
Global Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52
Global Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
Global Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal a As String, ByVal b As Long, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Long, ByVal h As Integer) As Long




Dim hwdc As Long
Dim startcap As Boolean
Private Sub cmdCapture_Click()
Dim temp As Long

hwdc = capCreateCaptureWindow("Dixanta Vision System", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
If (hwdc <> 0) Then
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
startcap = True
Else
MsgBox ("No Webcam found")
End If
End Sub

Private Sub cmdClose_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
startcap = False
End If
End Sub

Private Sub cmdVideoFormat_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
End If
End Sub

Feel free to contact me at dixanta@hotmail.com

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

dixanta


Hi,

Its Dixanta Shrestha here from Kathmandu, Nepal. I graduated from University of Ballarat(Sydney, Australia) in Bachelor's of Information Technology in 2005.

I started working as programmer since 2000 as visual Basic 6 and asp programmer. During my working period I worked on php,.net and java too and strong knowledge in Database like mysql,oracle,sql server and so on.

I enjoy programming and have finished several projects till now. Currently I work for my own and most of my clients are from Europe, Australia and America. So far I have positive feedback from all of my clients and hope that in future too.

If you are planning to give away your project on reasonable and competitive prices please feel free to contact me.

you can get me on following email addresses:
dixanta@hotmail.com
dixanta@yahoo.com
dixanta@gmail.com

Thank you

Occupation: Web Developer
Location: Australia Australia

Other popular VB.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh)FirstPrevNext
Questionwebcam image properties [modified]membernotsleepy2:52 25 Mar '08  
GeneralError catching & alternativemembershadesbass11:02 18 Dec '07  
Generala request from GHANASHYAMadminSean Ewington4:22 11 Oct '07  
Questionhelp !!!membermrqi7:44 29 Aug '07  
QuestionVB 2005 implementation?memberJohn_Mac16:57 20 Aug '06  
AnswerRe: VB 2005 implementation?memberCosi Fan Tutte21:55 23 Jan '07  
Questionhow to capture & save in image formatmemberKautsar13:39 29 Apr '06  
AnswerRe: how to capture & save in image formatmemberlengochuan4:35 19 Nov '06  
GeneralReal rate?membered id5:53 16 Mar '06  
GeneralArticle?memberjonathan154:37 13 Mar '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 11 Mar 2006
Editor:
Copyright 2006 by dixanta
Everything else Copyright © CodeProject, 1999-2008
Web07 | Advertise on the Code Project