Hi
With below API i am able to access Camera but i want that on click of button Image gets saved in a folder.
192.168.1.2/ISAPI/streaming/channels/01/picture. It asks for username and password
How this API can be used in VB6 code.
Thanks
Hi
With below API i am able to access Camera but i want that on click of button Image gets saved in a folder.
192.168.1.2/ISAPI/streaming/channels/01/picture. It asks for username and password
How this API can be used in VB6 code.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Eliana BlakeRank #1,595 · 993 reputationPosted Mar 17, 2025, 12:43 PM EDT
Hello! It's great to hear about your interest in accessing an IP camera API in VB6. To achieve your goal of saving an image to a folder upon clicking a button, you can follow these steps:
1. Making HTTP Requests: In VB6, you can make HTTP requests using the `MSXML2.XMLHTTP` object. Here's an example of how you can make a request to the camera's API and retrieve the image:
Dim objHTTP As Object Set objHTTP = CreateObject("MSXML2.XMLHTTP") Dim url As String Dim username As String Dim password As String url = "http://username:[email protected]/ISAPI/streaming/channels/01/picture" username = "your_username" password = "your_password" objHTTP.Open "GET", url, False, username, password objHTTP.send If objHTTP.Status = 200 Then Dim responseBody As Variant responseBody = objHTTP.responseBody ' Save the image to a file Dim outputStream As Object Set outputStream = CreateObject("ADODB.Stream") outputStream.Type = 1 ' Binary outputStream.Open outputStream.Write responseBody outputStream.SaveToFile "C:\Path\To\Your\Folder\image.jpg", 2 ' 2: Overwrite if exists outputStream.Close End If Set objHTTP = Nothing2. Button Click Event: You can trigger this code when a button is clicked in your VB6 form. Simply add a button control and place the above code inside its click event handler.
3. Adjusting the Code: Make sure to replace `your_username`, `your_password`, and the file path in `SaveToFile` with your actual credentials and desired saving location.
By implementing these steps, you should be able to access the camera's API, retrieve the image, and save it to a specified folder upon clicking the button in your VB6 application.
Feel free to ask if you have any further questions or need more assistance!
Sangeetha SRank #212 · 11.4K reputationPosted Mar 18, 2025, 2:43 AM EDT
Private Sub Command1_Click() SaveCameraImage "http://192.168.1.2/ISAPI/streaming/channels/01/picture", "username", "password", "C:\MyImages\camera_image_" & Format(Now, "yyyyMMdd_HHmmss") & ".jpg" End Sub Private Sub SaveCameraImage(ByVal sURL As String, ByVal sUsername As String, ByVal sPassword As String, ByVal sSavePath As String) Dim oHttp As WinHttp.WinHttpRequest Dim oStream As ADODB.Stream Dim bSuccess As Boolean On Error GoTo ErrorHandler Set oHttp = New WinHttp.WinHttpRequest oHttp.Open "GET", sURL, False ' Synchronous request oHttp.SetCredentials sUsername, sPassword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER oHttp.Send If oHttp.Status = 200 Then Set oStream = New ADODB.Stream oStream.Type = adTypeBinary oStream.Open oStream.Write oHttp.ResponseBody oStream.SaveToFile sSavePath, adSaveCreateOverWrite oStream.Close Set oStream = Nothing bSuccess = True MsgBox "Image saved successfully!", vbInformation Else MsgBox "Error: " & oHttp.Status & " - " & oHttp.StatusText, vbCritical bSuccess = False End If Set oHttp = Nothing Exit Sub ErrorHandler: MsgBox "An error occurred: " & Err.Description, vbCritical bSuccess = False If Not oHttp Is Nothing Then Set oHttp = Nothing If Not oStream Is Nothing Then oStream.Close: Set oStream = Nothing End Sub