473,651 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MciSendString

Could anyone tell me what am i doing bad?

When i use the "MciSendStr ing" always returns a big number instead 0 : What
it says that there is an error, and so don't play the sound.

Then direction of the sound .wav it's ok

I must not use any .ocx.

Could anyone compile it and tell me what it's wrong?

This is the code:

Public Class Form1
Inherits System.Windows. Forms.Form

Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA "
(ByVal lpstrCommand As String, ByVal lpstrReturnStri ng As String, ByVal
uReturnLength As Long, ByVal hwndCallback As Long) As Long
Declare Function mciGetErrorStri ng Lib "winmm.dll" Alias
"mciGetErrorStr ingA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
ByVal uLength As Long) As Long

Private Direccion As String
Private cadena As String

Sub MandarMensaje(B yVal mensaje As String)
Dim resultado As Long

cadena = Space(255)
resultado = mciSendString(m ensaje, cadena, Len(cadena), 0)
BuscarError(res ultado)
End Sub
Sub BuscarError(ByV al número As Long)
Dim errorBE As String

errorBE = Space(255)
mciGetErrorStri ng(número, errorBE, 255)
Label1.Text = errorBE
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
openFileDialog1 .InitialDirecto ry = CurDir() & "\Sonidos"
openFileDialog1 .FilterIndex = 1
openFileDialog1 .RestoreDirecto ry = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then
Direccion = openFileDialog1 .FileName

TextBox1.Text = Direccion

MandarMensaje(" close archivowav")
MandarMensaje(" open " & Direccion & " type waveaudio alias
archivowav")
MandarMensaje(" set archivowav time format milliseconds")
MandarMensaje(" status archivowav length")
If Val(Trim(cadena )) <0 Then ' Si dicho tiempo es distinto de 0
ProgressBar1.Mi nimum = 1
ProgressBar1.Ma ximum = Val(cadena)
ProgressBar1.Va lue = 1
Slider1.Minimum = 1
Slider1.Maximum = Val(cadena)
Slider1.Value = 1
End If
Label2.Text = Format(Val(cade na), "MM:SS")
End If
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
Timer1.Enabled = True
MandarMensaje(" play archivowav from 0")
End Sub

Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Timer1.Tick
MandarMensaje(" status archivowav position")
ProgressBar1.Va lue = Val(cadena)
Slider1.Value = Val(cadena)
Label2.Text = Format(Progress Bar1.Maximum - Val(cadena), "MM:SS")
End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
MandarMensaje(" stop archivowav")
Timer1.Enabled = False
End Sub

Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
If Button4.Text = "Pausa" Then
MandarMensaje(" pause archivowav")
Button4.Text = "Continuar"
Else
MandarMensaje(" resume archivowav")
Button4.Text = "Pausa"
End If
End Sub
End Class
Thanks everyone
--
Gracias a todos por colaborar
--
Gracias a todos por colaborar
May 7 '07 #1
1 6903
"César" <César@@discus sions.microsoft .comschrieb:
When i use the "MciSendStr ing" always returns a big number instead 0 :
What
it says that there is an error, and so don't play the sound.
[...]
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA "
(ByVal lpstrCommand As String, ByVal lpstrReturnStri ng As String, ByVal
uReturnLength As Long, ByVal hwndCallback As Long) As Long
Declare Function mciGetErrorStri ng Lib "winmm.dll" Alias
"mciGetErrorStr ingA" (ByVal dwError As Long, ByVal lpstrBuffer As String,
ByVal uLength As Long) As Long
Your declarations are wrong. Use these instead (untested):

\\\
Private Declare Auto Function mciSendString Lib "winmm.dll" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnStri ng As String, _
ByVal uReturnLength As UInt32, _
ByVal hwndCallback As IntPtr _
) As Int32

Private Declare Auto Function mciGetErrorStri ng Lib "winmm.dll" ( _
ByVal dwError As Int32, _
ByVal lpstrBuffer As String, _
ByVal uLength As UInt32 _
) As Int32
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

May 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3988
by: Jeroen van Vliet | last post by:
I made a program where wav files will be played from the database, with the full path.LIKE i = mciSendstring(open d:\sound.wav type waveaudio",0&,0,0) i = mciSendstring(play d:\sound.wav ",0&,0,0) This program will be written on a cdrom, in this case ithe cdrom volume is D: , but on other systems its not. How do i let the program choose the right volume?
0
1261
by: FRANCO | last post by:
Hello I need an help. I'm using MCI api to manage a video player. I know how to open a video , play it, stop it etc... and I know how to direct video on a pictureBox, but I'm not able get the video size so to adapt my pictureBox to the video size. I hope someone could help me bye telling me the mciSendString 's command to use for this purpose (and how to use it). thanks to everyone
0
1370
by: han.phony | last post by:
Hi, I am trying to intercept the message sent back by winmm.dll's mciSendString method when playback is finished. I tried to override the WndProc in the form but I didn't get/intercept the message, here is the code fragment: public const int MM_MCINOTIFY = 953; public const int MM_NOTIFY_ABORTED = 4;
3
2007
by: Dennis | last post by:
I am trying to use the Notify Flag to send a message when a song is finished playing. I got it to work by setting up a dummy window and overriding it's WndProc procedure then raising an event in my application. This work great until I open a new window then the Notify message doesn't seem to trigger the WinProc procedure in my dummy window. I guess it's because another window has the focus...is there any other way I can intercept this...
3
4970
by: Mark Denardo | last post by:
Does anyone have any good VB.NET example code that shows how to use the NOTIFY option using the mciSendString API and then handle the return value. The only examples I can find show the VB way using <Form>.hWnd My program basically needs to start a media file and then be informed when it has finished. Right now I have to set up a polling thread to check the status of the playing media file, which works, but causes other parts of my...
0
1421
by: kbodily | last post by:
Hi, I have this code in a dragdrop routine for a listview to get the duration of an mp3, where fPath is the path to the file that gets dropped Dim fname As String = Chr(34) + Trim(fPath) + Chr(34) mciSendString("open " & fname & " alias song", 0, 0, 0) Dim totalTime As String = Space(128) mciSendString("status song length", totalTime, 128, 0&) .Duration = totalTime
2
1737
by: BigC | last post by:
I am using the following line of code to save a voice file (.wav) to disk and it works fine when the filename contains no spaces. However the file doesn't get saved when its name contains a space. Does anyone know what is going wrong and how I can fix it ? nReturn = mciSendString("save Voice1 " & m_sVoiceFile, "0", 0, 0)
1
7027
by: _nabuchodonozor | last post by:
HI The mciSendString returns different value of tracks length than winamp. The value is longer about 20 seconds and I don't know why. Here is a code: public void SetTime() // I tried to set time format as it is said in MSDN help but it dosent work { sCommand = "set MediaFile time format hms";
1
1764
by: bajunaid | last post by:
Hi.. I'm trying to use mciSendString to play MP3 files and record WAV using mciSendString.. I did it successfully in a C# windowsApplicaton.. But when I move the same cod to my ASP file.. It just doesn't work.. I am using VS2005.. and I dont know what is the problem.. I have no errors,, it just doesn't work..
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.