Aug 20, 2014 at 8:00pm UTC
Can we start with WHAT the problem is? Thank you for using code tags but how did you manage to destroy your formatting?
Aug 20, 2014 at 10:34pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#define WIN32_LEAN_AND_MEAN // prevent windows.h from including "kitchen sink"
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main( int argc, char **argv )
{
argv[0]="\C:\\Documents and Settings\\Jason\\My Documents\\Jason\\My Music\\LOOKING LIKE THIS.wav\\0" ;
argv[1];
LPCSTR Application = "C:\\Program Files\\Windows Media Player\\wmplayer.exe" ;
// Media file extension must be provided
// Paths are quoted
char Command[1024] = "\"C:\\Program Files\\Windows Media Player\\wmplayer.exe\"" argv[0];
//Above this is what needs input.
STARTUPINFOA si = {0}; // zero struct
si.cb = sizeof (si);
PROCESS_INFORMATION pi = {0}; // zero struct
if ( CreateProcessA(Application,
Command,
NULL,
NULL,
FALSE,
NULL,
0,
NULL,
&si,
&pi)
)
{
cout << "Song playing\n" ;
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exitCode = 0;
GetExitCodeProcess(pi.hProcess, &exitCode);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
{
DWORD errCode = GetLastError();
cerr << "song playing failed\nError code: " << errCode << "\n" ;
}
}
I formatted your code into something more readable. What are you trying to do on line 16?
Last edited on Aug 20, 2014 at 10:34pm UTC
Aug 27, 2014 at 7:17pm UTC
I'm trying to be able to input the file directory there. That is where it is failing and I don't know why.
Aug 27, 2014 at 7:32pm UTC
What exactly are you trying to do with the arbitrary argv[0] on line 16?
Aug 27, 2014 at 7:36pm UTC
input a file directory
Ex: \C:\\Program Files\\Windows Media Player\\wmplayer.exe\
Aug 27, 2014 at 7:37pm UTC
Then why do you have the arbitrary argv[0] ? Remove it and it will do what you are wanting.
Also line 11 does nothing.
Last edited on Aug 27, 2014 at 7:38pm UTC
Aug 27, 2014 at 7:41pm UTC
I am trying to insert it in the console
Aug 27, 2014 at 11:13pm UTC
The trouble with that is argv[0] is generally the current directory and name of the process that is running. You want argv[1] for the first argument. Also, why aren't you just using std::string? You an concatenate the argument to your literal with the "std::string.append()" member function.
Aug 28, 2014 at 12:58am UTC
I don't use that because i don't know what that is or does
Aug 28, 2014 at 1:06am UTC
You don't use what? std::string? Are you serious? Would you like one of us to Google that for you, or would you rather just take a dip into our beloved forums dated tutorial?
Aug 28, 2014 at 10:26am UTC
could you just explain it or use lmgtfy.com? Im a noob.
Sep 2, 2014 at 9:40pm UTC
I still don't know what i'm doing...