| درود توی وی بی یک کلاس به نام clsWav ایجاد کنید و کد زیر رو توش Paste کنید
 .
 
 
 
 Private fName As StringPrivate Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
 Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
 Public Enum MyState
 Idle
 Recording
 Paused
 End Enum
 Private xState As MyState
 
 Public Function GetShortPath(strFileName As String) As String
 Dim lngRes As Long, strPath As String
 strPath = String$(165, 0)
 lngRes = GetShortPathName(strFileName, strPath, 164)
 GetShortPath = Left$(strPath, lngRes)
 End Function
 
 Public Property Get FileName() As String
 FileName = fName
 End Property
 
 Public Property Let FileName(ByVal sFileName As String)
 fName = sFileName
 End Property
 
 Public Function StartPlay() As Boolean
 mciSendString "close myplay", 0, 0, 0
 mciSendString "open " & fName & " type waveaudio alias myplay", 0, 0, 0
 mciSendString "play myplay", 0, 0, 0
 End Function
 Public Function StopPlay() As Boolean
 mciSendString "close myplay", 0, 0, 0
 End Function
 
 Public Function StartRecord() As Boolean
 On Error GoTo eR:
 If fName = "|" Then GoTo eR:
 Dim RS As String, cb As Long, i As Long
 RS = Space$(128)
 i = mciSendString("open new type waveaudio alias capture", RS, 128, cb)
 i = mciSendString("set capture bitspersample 16 channels 1 samplespersec 8000 BYTESPERSEC 16000 alignment 2", RS, 128, cb)
 i = mciSendString("Record Capture", RS, 128, cb)
 xState = Recording
 StartRecord = True
 Exit Function
 eR:
 StartRecord = False
 End Function
 
 Public Function StopRecord() As Boolean
 On Error GoTo eR:
 If fName = "|" Then GoTo eR:
 Dim RS As String, cb As Long, i As Long
 RS = Space$(128)
 
 i = mciSendString("save capture " & fName, RS, 128, cb)
 i = mciSendString("close capture", RS, 128, cb)
 xState = Idle
 StopRecord = True
 Exit Function
 eR:
 i = mciSendString("close capture", RS, 128, cb)
 StopRecord = False
 End Function
 
 Private Sub Class_Initialize()
 xState = Idle
 End Sub
 
 Private Sub Class_Terminate()
 StopRecord
 End Sub
 
 Public Function PauseRecord() As Boolean
 On Error GoTo eR:
 If fName = "|" Then GoTo eR:
 Dim RS As String, cb As Long, i As Long
 RS = Space$(128)
 If xState = Paused Then
 i = mciSendString("record capture", RS, 128, cb)
 xState = Recording
 ElseIf xState = Recording Then
 i = mciSendString("pause capture", RS, 128, cb)
 xState = Paused
 End If
 PauseRecord = True
 Exit Function
 eR:
 PauseRecord = False
 End Function
 
 
 Public Property Get State() As MyState
 State = xState
 End Property
 
 توی فرم اصلی برنامه (بالای همه
 کدها به صورت عمومی در کل فرم اصلی) یک کلاس جدید از این کلاس ایجاد
 کنید
 
 
 
 
 Dim cWav As New clsWav
 
 حالا براي ركورد توی فرم اصلی برنامه
 
 
 
 
 
 
 cWav.FileName = "c:\test.wav"cWav.StartRecord
 
 
 
 
  _______________________________________________________________________ پروژه های حرفه ای الکترونیک و کامپیوتر در www.khazama.com
مجموعه متن باز نامهای اصیل ایرانی
وبلاگ نوشته های شخصی من
 
 |