[SOLUCIONADO] Extraer sonidos de una DLL

Iniciado por aaronduran2, 15 Agosto 2008, 22:56 PM

0 Miembros y 1 Visitante están viendo este tema.

aaronduran2

Hola. Quisiera saber como extraer sonidos de una DLL. Tengo un código que permite extraer imágenes, pero lo que necesito es hacerlo con sonidos.

Código (vb) [Seleccionar]

Type GUID
     Data1 As Long
     Data2 As Integer
     Data3 As Integer
     Data4(7) As Byte
End Type

Type PicBmp
     Size As Long
     Type As Long
     hBmp As Long
     hPal As Long
     Reserved As Long
End Type


Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnHandle As Long, _
IPic As IPicture) As Long
Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" (ByVal hInstance As Long, ByVal lpBitmapID As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Declare Function FreeLibrary Lib "kernel32" _
               (ByVal hLibModule As Long) As Long
'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
'    //CargarImagenDLL//
'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
'   Cargar una imagen de una DLL.
'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
Public Function CargarImagenDLL(sDLL As String, ByVal lID As Long) As Picture
Dim hInst As Long
Dim hBmp  As Long
Dim Pic As PicBmp
     
Dim IPic As IPicture
Dim IID_IDispatch As GUID
Dim lRC As Long

     
hInst = LoadLibrary(sDLL)
If hInst <> 0 Then
    hBmp = LoadBitmap(hInst, lID)
    If hBmp <> 0 Then
        IID_IDispatch.Data1 = &H20400
        IID_IDispatch.Data4(0) = &HC0
        IID_IDispatch.Data4(7) = &H46
        Pic.Size = Len(Pic)
        Pic.Type = vbPicTypeBitmap
        Pic.hBmp = hBmp
        Pic.hPal = 0
        lRC = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
        If lRC = 0 Then
            Set CargarImagenDLL = IPic
            Set IPic = Nothing
        Else
            Call DeleteObject(hBmp)
        End If
    End If
    FreeLibrary (hInst)
    hInst = 0
End If
End Function


Gracias de antemano.

aaronduran2

Bueno, intentando conseguir algún resultado, hice esto:

Código (vb) [Seleccionar]

Private Const SND_SYNC = &H0              '  play synchronously (default)
Private Const SND_ASYNC = &H1             '  play asynchronously
Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
Private Const SND_MEMORY = &H4            '  lpszSoundName points to a memory file
Private Const SND_ALIAS = &H10000         '  name is a WIN.INI [sounds] entry
Private Const SND_FILENAME = &H20000      '  name is a file name
Private Const SND_RESOURCE = &H40004      '  name is a resource name or atom
Private Const SND_ALIAS_ID = &H110000     '  name is a WIN.INI [sounds] entry identifier
Private Const SND_ALIAS_START = 0         '  must be > 4096 to keep strings in same section of resource file
Private Const SND_LOOP = &H8              '  loop the sound until next sndPlaySound
Private Const SND_NOSTOP = &H10           '  don't stop any currently playing sound
Private Const SND_VALID = &H1F            '  valid flags          / ;Internal /
Private Const SND_NOWAIT = &H2000         '  don't wait if the driver is busy
Private Const SND_VALIDFLAGS = &H17201F   '  Set of valid flag bits.  Anything outside this range will raise an error
Private Const SND_RESERVED = &HFF000000   '  In particular these flags are reserved
Private Const SND_TYPE_MASK = &H170007

Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
'    //CargarSonidoDLL//
'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
'   Cargar un sonido de una DLL.
'#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
Public Sub CargarSonidoDLL(sDLL As String, ByVal lID As Long)
Const flags = SND_RESOURCE Or SND_ASYNC Or SND_NODEFAULT
Dim hInst As Long
Dim SonidoCargado As Variant
hInst = LoadLibrary(sDLL)
If hInst <> 0 Then
    SonidoCargado = PlaySound(CStr("#" & lID), hInst, flags)
End If
DoEvents
FreeLibrary (hInst)
hInst = 0
End Sub

Así que el problema está solucionado.

Saludos.