elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Load wav file from res in a dll
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: Load wav file from res in a dll  (Leído 7,221 veces)
ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Load wav file from res in a dll
« en: 18 Enero 2010, 19:56 pm »

Good  evening 
I  try  this time  to load a res wav file from  dll   .but  no luck   
use this  example 
but  i dont  know  what the  wrong 
i successed to load from main project  and after try from dll  but something is wrong   
someone  can point me to  the correct way   




En línea

ssccaann43 ©


Desconectado Desconectado

Mensajes: 792


¬¬


Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #1 en: 18 Enero 2010, 20:39 pm »

You need to upload the file .RES in the project and then want to upload .DLL file?
I do not know much you need to do. Do you have a source?


En línea

- Miguel Núñez
Todos tenemos derechos a ser estupidos, pero algunos abusan de ese privilegio...
"I like ^TiFa^"
el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #2 en: 18 Enero 2010, 20:45 pm »

Good  evening 
I  try  this time  to load a res wav file from  dll   .but  no luck   
use this  example 
but  i dont  know  what the  wrong 
i successed to load from main project  and after try from dll  but something is wrong   
someone  can point me to  the correct way   




hi nyaryl, well, i remember that .. isnt hard... here you got a TIP to do that:
http://www.devx.com/tips/Tip/12595

by
En línea

'-     coco
"Te voy a romper el orto"- Las hemorroides
ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #3 en: 18 Enero 2010, 22:11 pm »

thanks  for the  fast reply  
this  is my  example  
http://rapidshare.com/files/337400568/res-dll.rar.html
thanks  for the  tips  El_coco
in  local way  is  ok    
only with the dll  i  cant  
Thanks  for the time  

the example  come  from  thevbzone
« Última modificación: 18 Enero 2010, 22:19 pm por ntaryl » En línea

el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #4 en: 18 Enero 2010, 23:00 pm »

thanks  for the  fast reply 
this  is my  example   
http://rapidshare.com/files/337400568/res-dll.rar.html
thanks  for the  tips  El_coco
in  local way  is  ok   
only with the dll  i  cant   
Thanks  for the time 

the example  come  from  thevbzone


i think you could load the dll, and get it hInstance, so, use that instead app.hinstance. i really dont know if it will work, but you can check.

BTW. i can't download your example, beacause stupid rapid share is overloaded!

by
En línea

'-     coco
"Te voy a romper el orto"- Las hemorroides
seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: Load wav file from res in a dll
« Respuesta #5 en: 19 Enero 2010, 01:22 am »

the code in the Command3 is wrong...this line of code:

Código
  1. strFilePath = "\Sound.dll"

replace with this:

Código
  1. strFilePath = "Sound.dll"

the line "\" is wrong...

and this:

Código
  1. hResource = FindResource(hLibrary, "#101" & CStr(1) & Chr(0), "wave" & Chr(0))

replace with this:

Código
  1. hResource = FindResource(hLibrary, "#101", "CUSTOM")

The final code is:

Código
  1. Dim strString As String
  2.    Dim so  As Integer
  3.    Dim lngStringLen As Long, hResource As Long, hdata As Long
  4.    Dim lpData As Long
  5.    Dim strFilePath As String
  6.    Dim hLibrary As Long
  7.    strFilePath = "Sound.dll"
  8.    hLibrary = LoadLibrary(strFilePath & Chr(0))
  9.    hResource = FindResource(hLibrary, "#101", "CUSTOM")
  10.    hdata = LoadResource(hLibrary, hResource)
  11.    lpData = LockResource(hdata)
  12.    PlaySound ByVal lpData, 0, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
  13.    FreeLibrary hLibrary

the sound sounds good...

greetings.
En línea

el_c0c0


Desconectado Desconectado

Mensajes: 307


Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #6 en: 19 Enero 2010, 01:42 am »

...

very good seba. and the thing to use SND_ASYNC its good too, to not lock the process.

bye
En línea

'-     coco
"Te voy a romper el orto"- Las hemorroides
ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #7 en: 19 Enero 2010, 16:08 pm »

Thanks  guys  for  the  answer  
and  also to spent  time  in my post
    .
seba123neo : i  change the  commend3 with  this  code and  when  run the  project  crash  my  vb ide
also  when  run it  compile  crash  again  
in  ur pc  work  fine   ?
thanks  for the time  

http://img521.imageshack.us/img521/7886/errorwx.jpg


thanks  for  ur  time  also El_coco

En línea

ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Load wav file from res in a dll
« Respuesta #8 en: 19 Enero 2010, 18:17 pm »

thanks  again   
with  this  example  my  project  crash 
i  try  to use it again   
and  this  work   
Código:
Dim strFilePath As String
   Dim hLibrary As Long
   Dim hResource As Long
   Dim hData As Long
   Dim lpData As Long
   ' Get the path to the Resource DLL
   strFilePath = "Sound.dll"
   ' Load the Resource DLL
   hLibrary = LoadLibrary(strFilePath & Chr(0))
   If hLibrary = 0 Then
      MsgBox "Failed to load the specified library with error code " & Err.LastDllError
      Exit Sub
   End If
   ' Get a .WAV file from the Resource DLL
   hResource = FindResource(hLibrary, "#101", "CUSTOM")
   If hResource <> 0 Then
      hData = LoadResource(hLibrary, hResource) 'This gets a handle to the data
      If hData <> 0 Then
         lpData = LockResource(hData) 'This gets a POINTER to the data... which is what we need
         If lpData <> 0 Then
            PlaySound ByVal lpData, 0, SND_MEMORY Or SND_NODEFAULT Or SND_SYNC
         End If
      End If
   End If
   
   ' Close the Resource DLL
   FreeLibrary hLibrary
have a good  afternoon
En línea

cobein


Desconectado Desconectado

Mensajes: 759



Ver Perfil WWW
Re: Load wav file from res in a dll
« Respuesta #9 en: 19 Enero 2010, 20:23 pm »

Actually theres a simpler way to do it, the only thing you have to do is use some resource editor(Resource Builder will work) add the resource as WAVE instead of CUSTOM and then some code like this one.

Código:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Declare Function LoadLibraryEx Lib "kernel32" Alias "LoadLibraryExA" (ByVal lpLibFileName As String, ByVal hFile As Long, ByVal dwFlags As Long) As Long

Private Const LOAD_LIBRARY_AS_DATAFILE As Long = &H2
Private Const SND_ASYNC As Long = &H1
Private Const SND_RESOURCE As Long = &H40004


Private Sub Form_Load()
    Dim lLib As Long
    
    lLib = LoadLibraryEx("C:\Documents and Settings\Cobein\Escritorio\proyecto1.dll", 0, LOAD_LIBRARY_AS_DATAFILE)
    Debug.Print PlaySound("WAVE_0", lLib, SND_ASYNC Or SND_RESOURCE)
    
End Sub
En línea

http://www.advancevb.com.ar
Más Argentino que el morcipan
Aguante el Uvita tinto, Tigre, Ford y seba123neo
Karcrack es un capo.
Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Can't load IA 32-bit
Java
juancaa 1 3,803 Último mensaje 30 Enero 2013, 17:13 pm
por juancaa
Load data
PHP
mysqlway 2 2,032 Último mensaje 15 Enero 2015, 17:29 pm
por el-brujo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines