Video Capture - Send Message WM_CAP_FILE_SAVEAS can't convert path to long?

sspears2020

New member
Joined
Nov 11, 2010
Messages
3
Programming Experience
1-3
Hello all,

I am making a video capture project using SendMessage and WM_CAP_FILE_SAVEAS. I have seen numerous examples online of how to do this, however I cannot get my filepath to work, it keeps saying that it can't convert. I dont understand this because every example had it written out the same way I did? Here are the pieces of code relating to the save portion.

Constants:

VB.NET:
Const WM_CAP As Short = &H400S
    Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
    Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
    Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
    Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
    Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
    Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
    Const WS_CHILD As Integer = &H40000000
    Const WS_VISIBLE As Integer = &H10000000
    Const SWP_NOMOVE As Short = &H2S
    Const SWP_NOSIZE As Short = 1
    Const SWP_NOZORDER As Short = &H4S
    Const HWND_BOTTOM As Short = 1
    Const WM_CAP_FILE_SAVEAS As Integer = WM_CAP + 23
    Const WM_CAP_SEQUENCE As Integer = WM_CAP + 62

Declaring function:

VB.NET:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
        (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, _
         ByVal lParam As IntPtr) As Integer

Button event triggering the saveas:

VB.NET:
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        btnTestStart.Enabled = True
        btnStop.Enabled = False

        'SAVE FILE = giving the error, can't convert string path to an integer?
        SendMessage(hHwnd, WM_CAP_FILE_SAVEAS, 0, "C:\users\sspears\desktop\video.avi")

    End Sub
 
Update:

I thought the reason I couldn't change the lParam value to a string was because it caused an error earlier on in my code, however it seems that I can. Now it works... haha
 
SendMessage is used for many different purposes, with various types of input. In VB you usually can define the function parameter types to suit the needs, and when there is different needs you can use overloads that has different parameter types. For this message I guess you can declare the lParam parameter "As String", thus pass in a String value without any conversion or other handling.
 
Back
Top