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

Visual Basic

 
GeneralRe: VB6 Compile "unexpected error" Pin
Dave Kreskowiak18-Jul-12 2:19
mveDave Kreskowiak18-Jul-12 2:19 
GeneralRe: VB6 Compile "unexpected error" Pin
MikeD 218-Jul-12 5:47
MikeD 218-Jul-12 5:47 
GeneralRe: VB6 Compile "unexpected error" Pin
Dave Kreskowiak18-Jul-12 7:33
mveDave Kreskowiak18-Jul-12 7:33 
JokeRe: VB6 Compile "unexpected error" Pin
Paul Conrad18-Jul-12 9:40
professionalPaul Conrad18-Jul-12 9:40 
GeneralRe: VB6 Compile "unexpected error" Pin
Bernhard Hiller18-Jul-12 2:29
Bernhard Hiller18-Jul-12 2:29 
GeneralRe: VB6 Compile "unexpected error" Pin
MikeD 218-Jul-12 5:50
MikeD 218-Jul-12 5:50 
GeneralRe: VB6 Compile "unexpected error" Pin
Bernhard Hiller18-Jul-12 21:03
Bernhard Hiller18-Jul-12 21:03 
QuestionmciSendCommand in VB.NET Pin
kingneb17-Jul-12 5:52
kingneb17-Jul-12 5:52 
On MSDN, I found code that is designed to change between multiple sound cards on a PC. I need to do this in .NET. I attemped to translate the VB6 code on MSDN (see link) into .NET but wind up with a PInvokeStackImbalence exception.

http://support.microsoft.com/kb/180032[^]

Here is my attempted translation:

VB
Imports System.Runtime.InteropServices

'Media Manager relegates the playing of *.wav files over multiple sound cards.
Public Class MediaManager

    'Parameters for mciSendCommand dwParam2.
    Structure MCI_WAVE_SET_PARMS
        Dim dwCallback As Long
        Dim dwTimeFormat As Long
        Dim dwAudio As Long
        Dim wInput As Long
        Dim wOutput As Long
        Dim wFormatTag As Integer
        Dim wReserved2 As Integer
        Dim nChannels As Integer
        Dim wReserved3 As Integer
        Dim nSamplesPerSec As Long
        Dim nAvgBytesPerSec As Long
        Dim nBlockAlign As Integer
        Dim wReserved4 As Integer
        Dim wBitsPerSample As Integer
        Dim wReserved5 As Integer
    End Structure

    Public Enum SoundFlags As UInteger
        SND_SYNC = &H0          ' play synchronously (default)
        SND_ASYNC = &H1         ' play asynchronously
        SND_NODEFAULT = &H2     ' silence (!default) if sound not found
        SND_MEMORY = &H4        ' pszSound points to a memory file
        SND_LOOP = &H8          ' loop the sound until next sndPlaySound
        SND_NOSTOP = &H10       ' don't stop any currently playing sound
        SND_NOWAIT = &H2000     ' don't wait if the driver is busy
        SND_ALIAS = &H10000     ' name is a registry alias
        SND_ALIAS_ID = &H110000 ' alias is a predefined id
        SND_FILENAME = &H20000  ' name is file name
        SND_RESOURCE = &H40004  ' name is resource name or atom
    End Enum

    'Plays a *.wav file denoted by a file name.
    Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal pszSound As String, ByVal hmod As UInteger, ByVal fdwSound As UInteger) As Boolean

    'Used to change between different sound cards.
    Private Declare Auto Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByRef dwParam2 As MCI_WAVE_SET_PARMS) As Long

    Sub New()
        Dim Parameters As MCI_WAVE_SET_PARMS
        mciSendCommand(0, &H80D, &H800000, Parameters)
        PlaySound("C:\thermo.wav", 0, SoundFlags.SND_FILENAME Or SoundFlags.SND_ASYNC Or SoundFlags.SND_LOOP)
    End Sub



End Class


Can Anyone assist me?
Thanks,
kingneb

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 
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 

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.