Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Mi4night

#11
Programación Visual Basic / [VB6]mPlayWAV
2 Mayo 2010, 02:57 AM
Bueno aquí un pequeño módulo para agregar sonidos wav a su aplicación selecciona entre el archivo local o jugar de Recursos.
(Google Translator)

Option Explicit
'---------------------------------------------------------------------------------------
' Module      : mPlayWAV
' DateTime    : 20/04/2010  01:58AM
' Author      : Mi4night
' Mail        : mi4night@hotmail.com
'Special Thx  : MSDN
' Purpose     : Play a wav file from Resource or File
' Usage       : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce
'               or publish this code on any web site,
'               online service, or distribute as source
'               on any media without express permission.
'
'---------------------------------------------------------------------------------------

'Used API declaration
Private Declare Function sndPlaySound _
                Lib "winmm.dll" _
                Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
                                       ByVal uFlags As Long) As Long
Private Declare Function PlaySoundData _
                Lib "winmm.dll" _
                Alias "PlaySoundA" (lpData As Any, _
                                    ByVal hModule As Long, _
                                    ByVal dwFlags As Long) As Long

'Enumuration to select the way of playing the file
Public Enum PlayType
    WAVFromRes = 0
    FromFile = 1
End Enum

'Flags used by API
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Const SND_MEMORY = &H4

'Buffer for the Resource WAV File
Dim ResData() As Byte

Public Function PlayWAVSound(PType As PlayType, _
                             Optional ResID As Integer = 0, _
                             Optional ResType As String = vbNullChar, _
                             Optional WavPath As String = vbNullChar) As Integer
    'Simple error handling
    On Error GoTo errHandle:
   
    Const Flags = SND_MEMORY Or SND_ASYNC Or SND_NODEFAULT
   
    'Are any parameters used ?
    If ResID = 0 And WavPath = "" Then
        Exit Function
       
    Else

        'What king of playing type is selected ?
        Select Case PType

            Case 0
                ResData = LoadResData(ResID, ResType)
                PlayWAVSound = PlaySoundData(ResData(0), 0, Flags)

            Case 1
                PlayWAVSound = sndPlaySound(WavPath, SND_ASYNC Or SND_NODEFAULT)
       
        End Select

    End If

    Exit Function
    'Error handling
errHandle:
    MsgBox "Error Code: " & Err.Number & vbCrLf & "Error Description: " & _
    Err.Description, vbCritical, "Error"

End Function
#12
Programación Visual Basic / [VB6]mFileSize
2 Mayo 2010, 02:54 AM
Bueno esto es sólo una función sencilla de determinar el tamaño de archivo de un archivo.

Option Explicit
'---------------------------------------------------------------------------------------
' Module      : mFileSize
' DateTime    : 25/12/09 02:19
' Author      : Mi4night
' Mail        : mi4night@hotmail.com
' Usage       : At your own risk.
' Purpose     : Get the size of a file
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce
'               or publish this code on any web site,
'               online service, or distribute as source
'               on any media without express permission.
'---------------------------------------------------------------------------------------
Private Declare Function GetCompressedFileSize _
                Lib "kernel32" _
                Alias "GetCompressedFileSizeA" (ByVal lpFileName As String, _
                                                lpFileSizeHigh As Long) As Long

Public Function GetFileSize(FilePath As String) As String
    'Variable Declaration
    Dim FSize As Double
   
    'Verify that the FilePath is given
    If Len(FilePath) <> 0 Then
       
        'Getting FileSize in bit
        FSize = GetCompressedFileSize(FilePath, ByVal 0&)

        If FSize < "1024" Then
            GetFileSize = FSize & " Bytes"
        ElseIf FSize >= "1024" And FSize < "1048576" Then
            GetFileSize = Round(FSize / 1024, 2) & " KB"
        ElseIf FSize >= "1048576" Then
            GetFileSize = Round(FSize / 1048576, 2) & " MB"
        End If

    Else
        Exit Function
    End If

End Function