Click here to Skip to main content
15,879,535 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionmciSendCommand in VB.NET Pin
kingneb17-Jul-12 5:52
kingneb17-Jul-12 5:52 
AnswerRe: mciSendCommand in VB.NET Pin
Luc Pattyn17-Jul-12 6:21
sitebuilderLuc Pattyn17-Jul-12 6:21 
GeneralRe: mciSendCommand in VB.NET Pin
kingneb17-Jul-12 6:45
kingneb17-Jul-12 6:45 
AnswerRe: mciSendCommand in VB.NET Pin
Luc Pattyn17-Jul-12 6:55
sitebuilderLuc Pattyn17-Jul-12 6:55 
GeneralRe: mciSendCommand in VB.NET Pin
Dave Kreskowiak17-Jul-12 11:05
mveDave Kreskowiak17-Jul-12 11:05 
AnswerRe: mciSendCommand in VB.NET Pin
Bernhard Hiller17-Jul-12 20:50
Bernhard Hiller17-Jul-12 20:50 
AnswerRe: mciSendCommand in VB.NET Pin
Sasha Laurel18-Jul-12 13:18
Sasha Laurel18-Jul-12 13:18 
AnswerRe: mciSendCommand in VB.NET Pin
Sasha Laurel19-Jul-12 9:10
Sasha Laurel19-Jul-12 9:10 
If I change the datatypes in the method declaration, and change the way its called by using Marshal to copy the values back and forth from unmanaged. I am getting a result of 257 which means 'Invalid DeviceID' which is expected since we passed it 0 as a deviceID.

Example:
'Used to change between different sound cards.
Private Declare Auto Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As UInteger, ByVal uMessage As UInteger, ByVal dwFlags As IntPtr, ByRef dwParam2 As IntPtr) As Integer

Public Sub TestMciSendCommand()
    Dim Parameters As MCI_WAVE_SET_PARMS
    Dim fwdCmd, dwParam As IntPtr
    Dim mciResult As Integer
    Dim deviceID As UInteger

    Try
        dwParam = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(MCI_WAVE_SET_PARMS)))
        Marshal.StructureToPtr(Parameters, dwParam, False)

        fwdCmd = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(Integer)))
        Marshal.WriteInt32(fwdCmd, &H800000)

        deviceID = 0 ' TODO: Get the actual deviceID

        ' results in error # 257 - MCIERR_INVALID_DEVICE_ID
        mciResult = mciSendCommand(deviceID, &H80D, fwdCmd, dwParam)

        Parameters = CType(Marshal.PtrToStructure(dwParam, GetType(MCI_WAVE_SET_PARMS)), MCI_WAVE_SET_PARMS)

    Catch ex As Exception
        Debug.WriteLine(String.Format("mciSendCommand Failed with message: {0}", ex.Message))
        Debug.WriteLine(ex)

    Finally
        ' Clean up unmanaged memory allocations!
        Marshal.FreeHGlobal(fwdCmd)
        Marshal.FreeHGlobal(dwParam)
    End Try
End Sub


Error Codes Reference[^]

Hopefully all that remains is to find the proper deviceID. Best of luck to you.
Generalplease upload Pin
MD Chalodiya16-Jul-12 20:02
MD Chalodiya16-Jul-12 20:02 
AnswerRe: please upload Pin
Eddy Vluggen16-Jul-12 21:50
professionalEddy Vluggen16-Jul-12 21:50 
GeneralBound datagridview with unbound combobox Column - Problems Pin
alejx16-Jul-12 14:48
alejx16-Jul-12 14:48 
GeneralRe: Bound datagridview with unbound combobox Column - Problems Pin
Sasha Laurel18-Jul-12 13:23
Sasha Laurel18-Jul-12 13:23 
GeneralSearchprogram for text in multi excel sheets Pin
abjac@16-Jul-12 6:23
abjac@16-Jul-12 6:23 
QuestionRe: Searchprogram for text in multi excel sheets Pin
Richard MacCutchan16-Jul-12 7:45
mveRichard MacCutchan16-Jul-12 7:45 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@16-Jul-12 10:30
abjac@16-Jul-12 10:30 
GeneralRe: Searchprogram for text in multi excel sheets Pin
JR21216-Jul-12 19:01
JR21216-Jul-12 19:01 
GeneralRe: Searchprogram for text in multi excel sheets Pin
Richard MacCutchan16-Jul-12 21:16
mveRichard MacCutchan16-Jul-12 21:16 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@16-Jul-12 22:35
abjac@16-Jul-12 22:35 
GeneralRe: Searchprogram for text in multi excel sheets Pin
Richard MacCutchan16-Jul-12 22:50
mveRichard MacCutchan16-Jul-12 22:50 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@16-Jul-12 23:23
abjac@16-Jul-12 23:23 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@17-Jul-12 5:44
abjac@17-Jul-12 5:44 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@18-Jul-12 10:48
abjac@18-Jul-12 10:48 
GeneralRe: Searchprogram for text in multi excel sheets Pin
Richard MacCutchan18-Jul-12 21:43
mveRichard MacCutchan18-Jul-12 21:43 
GeneralRe: Searchprogram for text in multi excel sheets Pin
abjac@19-Jul-12 0:40
abjac@19-Jul-12 0:40 
GeneralRe: Searchprogram for text in multi excel sheets Pin
Richard MacCutchan19-Jul-12 2:05
mveRichard MacCutchan19-Jul-12 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.