# c++ code help



## ste2425 (Apr 4, 2010)

is it possible in c++ a function that when called will start any windows programme i choose? like windows media player for example? I want to make some very basic form a voice recognition software i have an idea on how to get the audio bit to recognise what im saying but i have no idea to to make it open the programme i say.
stephen


----------



## erocker (Apr 4, 2010)

Sure it's possible, do you have any C++ knowledge? If not, it's probably best to get some first. Lots of links here: http://forums.techpowerup.com/showthread.php?t=31132

C++ tutorials: http://www.cplusplus.com/doc/tutorial/

Perhaps you may find something that works better for you than C++. I'm still skimming though all the links and I'm starting to learn.


----------



## ste2425 (Apr 4, 2010)

erocker said:


> Sure it's possible, do you have any C++ knowledge? If not, it's probably best to get some first. Lots of links here: http://forums.techpowerup.com/showthread.php?t=31132
> 
> Perhaps you may find something that works better for you than C++. I'm still skimming though all the links and I'm starting to learn.



aye i do ive almost finished my first year of programming for audio systems at uni, next year im doing programming for windows and embeded systems,

i think i found out a way to be onest, it was allot easier then i expected.



> using: system(), CreateProcess() and ShellExecute()


----------



## Kreij (Apr 4, 2010)

I'm a little rusty on my C++, but the ShellExecute() function may do what you need.


----------



## erocker (Apr 4, 2010)

ste2425 said:


> aye i do ive almost finished my first year of programming for audio systems at uni, next year im doing programming for windows and embeded systems,
> 
> i think i found out a way to be onest, it was allot easier then i expected.



Heh, you're way further ahead than me. I just started reading. I haven't "coded" anything since my Commodore 64. I figure I have a couple good application ideas for Droid/iphone and I might as well start doing something about them.


----------



## Kreij (Apr 4, 2010)

Erocker said:
			
		

> I haven't "coded" anything since my Commodore 64



Get with the program you slacker. 

I used to do a lot in C/C++, but since I've been doing a lot of Database stuff, C# seems to a good fit. I was dabbling in F#, but can't find a real need for it.
Maybe it's time to dig back in so I can be of more help here. Seems a lot of people, especially in school, need C++ assistance.


----------



## dcf-joe (Apr 4, 2010)

Yeah, whenever you code your function and you want to start Windows Media Player, all you have to do it:

void startMediaPlayer() // This function header is completely randomly created, it can say anything
{
*system("start wmplayer.exe");*
}

Remember, you can start any executable, just go to task manager to find out what the official executable name is so that you can call system("blah.exe")


----------



## ste2425 (Apr 5, 2010)

dcf-joe said:


> Yeah, whenever you code your function and you want to start Windows Media Player, all you have to do it:
> 
> void startMediaPlayer() // This function header is completely randomly created, it can say anything
> {
> ...



so i dont need to give the file path? like c:\ program files etc etc etc? i also heard that using system locks the code there until you close whatever exe you opened? does it?

edit no it doean't lock up just tested cheers that will work perfect for what i need 
All i need to do next it work out how to use a mic a record a bit of audio good job im doing that soon at uni


----------



## dcf-joe (Apr 5, 2010)

Thank you for the thanks, and you are welcome. I am kind of a beginner myself, but I have had to use that system call before and it works perfectly 

No, you do not have to provide system paths, you JUST have to know the executable name, and if you are using a 64-bit operating system, you DO NOT have to provide the *32 flag at the end of the executable name, the operating system already knows


----------



## Kreij (Apr 6, 2010)

I think to launch an executable without the full path, the directory name has to be in the "Path" enviroment variable.


----------



## ste2425 (Apr 6, 2010)

dcf-joe said:


> Thank you for the thanks, and you are welcome. I am kind of a beginner myself, but I have had to use that system call before and it works perfectly
> 
> No, you do not have to provide system paths, you JUST have to know the executable name, and if you are using a 64-bit operating system, you DO NOT have to provide the *32 flag at the end of the executable name, the operating system already knows



what if your running on 32 bit systems though? this just for personall use an my systems 64bit but if it turns out anygood and of any use it might give u guys the code to mess bout with


----------



## dcf-joe (Apr 7, 2010)

Does not matter if 32 or 64 bit. The operating system knows what it is when it runs the executable.

 I am just saying, if you are running a 64-bit operating system and you are trying to run a 32-bit executable, you do not have to include that flag at the end, because the operating system knows what it is before it runs it.

As for trying to run a 64-bit executable in a 32-bit environment, if I recall correctly, Microsoft released an update a few years back to allow that to work, somehow  I am sure it would work the same way though.


----------



## ste2425 (Apr 7, 2010)

dcf-joe said:


> Does not matter if 32 or 64 bit. The operating system knows what it is when it runs the executable.
> 
> I am just saying, if you are running a 64-bit operating system and you are trying to run a 32-bit executable, you do not have to include that flag at the end, because the operating system knows what it is before it runs it.
> 
> As for trying to run a 64-bit executable in a 32-bit environment, if I recall correctly, Microsoft released an update a few years back to allow that to work, somehow  I am sure it would work the same way though.



ok thats great cheers


----------

