Click to See Complete Forum and Search --> : mcisendstring


zaryk
April 26th, 2008, 01:52 PM
I am using mcisendstring in my code, and was quite happy to find that it was easy to implement.



mciSendString("open myFile type mpegvideo alias myFile", NULL, 0, 0);

mciSendString("play myFile", NULL, 0, 0);



Is there a way to use a variable as myFile.



string myFile;

mciSendString("open " + myFile + " type mpegvideo alias myFile", NULL, 0, 0);

mciSendString("play myFile", NULL, 0, 0);



If i use a string it errors this:


49 C:\Documents and Settings\user\My Documents\SharpDevelop Projects\c++\winapi\main2.cpp cannot convert `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to `const CHAR*' for argument `1' to `MCIERROR mciSendStringA(const CHAR*, CHAR*, UINT, HWND__*)'


if i use char*:



49 C:\Documents and Settings\user\My Documents\SharpDevelop Projects\c++\winapi\main2.cpp invalid operands of types `char*' and `const char[100]' to binary `operator+'

Martin O
April 26th, 2008, 02:26 PM
Thats a problem with strings. Nothing to do with mciSendString. You should write yourself a small test program to solidify your understanding of std::string, string literals, char*, etc, etc. For instance, before trying to create that string & use it as an argument to mciSendString, I'd write a small program to create that string & print it out with std::cout.

Here's a tutorial on strings:

http://www.cprogramming.com/tutorial/string.html

zaryk
April 26th, 2008, 02:57 PM
I figured it out without your insulting link of printing out strings, especially since i have a c++ class, making an "A", and the teacher tells me to help the other students. I was thinking c# thats what was wrong. But then again I probably deserved that insult as to thinking that people had higher intelligences, especially when I dont post all the code, cuz im thinking people are smarter than that.

Plasmator
April 26th, 2008, 05:11 PM
I figured it out without your insulting link of printing out strings, especially since i have a c++ class, making an "A", and the teacher tells me to help the other students.Congratulations, you're awesome.

At least have the decency to thank Martin for replying to your post, instead of calling his link "insulting"...

zaryk
April 27th, 2008, 12:52 PM
well, at least have the decency to post something useful.

Plasmator
April 27th, 2008, 01:08 PM
Teaching you some manners is useful, indeed.

zaryk
April 27th, 2008, 01:17 PM
this has nothing to do with me not knowing manners, but that I choose not to use them, so your post was useless. Plus, my mother always told me to tell the truth, and I was telling the truth when I said that his link was insulting.

Plasmator
April 27th, 2008, 01:19 PM
this has nothing to do with me not knowing manners, but that I choose not to use them, so your post was useless.Get over yourself.

How can you expect to receive help if you're going to act like a little kid?

zaryk
April 27th, 2008, 01:31 PM
You better be glad that Jim fell asleep before he saw that, he would have taken that as an insult too, especially since he is 7. This is James, Im the main person in this head of mine or maybe that was Bob but anyway, Im 19. I have multiple-personality disorder. I am one out of 15, that I have counted so far. Sorry for his behavior.