Results 1 to 4 of 4

Thread: Thread for playing of Wav file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Posts
    71

    Question Thread for playing of Wav file

    Can i create a separate thread for the playing of a wav file using mcisendstring?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Separete threads are created using CreateThread API. It is not very simple.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Here is a simple example
    Code:
    'In a form
    'Add a command button to the form
    Private Sub Command1_Click()
        'After you click this button, try to move the window
        'You will see that the AsyncThread-function was executed asynchronously
        hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf AsyncThread, ByVal 0&, ByVal 0&, hThreadID)
        CloseHandle hThread
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'If the thread is still running, close it
        If hThread <> 0 Then TerminateThread hThread, 0
    End Sub
    'In a module
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
    Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Public hThread As Long, hThreadID As Long
    Public Sub AsyncThread()
        'Let this thread sleep for 10 seconds
        Sleep 10000
        hThread = 0
    End Sub
    Parameter info
    Code:
    · lpThreadAttributes
    Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpThreadAttributes is NULL, the handle cannot be inherited.
    Windows NT: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new thread. If lpThreadAttributes is NULL, the thread gets a default security descriptor.
    Windows 95: The lpSecurityDescriptor member of the structure is ignored.
    
    · dwStackSize
    Specifies the size, in bytes, of the stack for the new thread. If 0 is specified, the stack size defaults to the same size as that of the primary thread of the process. The stack is allocated automatically in the memory space of the process and it is freed when the thread terminates. Note that the stack size grows, if necessary.
    CreateThread tries to commit the number of bytes specified by dwStackSize, and fails if the size exceeds available memory.
    
    · lpStartAddress
    The starting address of the new thread. This is typically the address of a function declared with the WINAPI calling convention that accepts a single 32-bit pointer as an argument and returns a 32-bit exit code. Its prototype is:
    DWORD WINAPI ThreadFunc( LPVOID );
    
    · lpParameter
    Specifies a single 32-bit parameter value passed to the thread.
    
    · dwCreationFlags
    Specifies additional flags that control the creation of the thread. If the CREATE_SUSPENDED flag is specified, the thread is created in a suspended state, and will not run until the ResumeThread function is called. If this value is zero, the thread runs immediately after creation. At this time, no other values are supported.
    
    · lpThreadId
    Points to a 32-bit variable that receives the thread identifier.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Megatron
    Guest
    Your statements contradict eachother, Vlatko.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width