Run copy command in the background using vc++
-
Hi All I am using copy command to join two files. It works fine when I am using this in the command prompt But I want to run this command in the background using vc++. so please tell me how I run this command in the background. copy /b "first file path"+"second file path" "outfilepath"
-
Hi All I am using copy command to join two files. It works fine when I am using this in the command prompt But I want to run this command in the background using vc++. so please tell me how I run this command in the background. copy /b "first file path"+"second file path" "outfilepath"
You can use the
system
function to execute the command. But it is preferable to use the file operation APIs likeCreateFile
andWriteFile
to achieve the same.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
You can use the
system
function to execute the command. But it is preferable to use the file operation APIs likeCreateFile
andWriteFile
to achieve the same.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Thanks for reply I try system command Its working fine but the command window is show. I want also hide this command window. actually i am joining mp3 file so thats why i am using copy command.
To hide the command window you will have to do a lot more work. You will need to use
CreateProcess
to start the command prompt (Cmd.exe) and specifyingCREATE_NO_WINDOW
in thedwCreationFlags
parameter. If this doesn't work you can set theSTARTF_USESHOWWINDOW
flag in theSTARTUPINFO
structure and set itswShowWindow
member toSW_HIDE
. The copy command will need to be given as parameter to the Cmd.exe. Instead it will be easier to use the file APIs likeCreateFile
andWriteFile
.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Hi All I am using copy command to join two files. It works fine when I am using this in the command prompt But I want to run this command in the background using vc++. so please tell me how I run this command in the background. copy /b "first file path"+"second file path" "outfilepath"
I dont think its better to use copy command, instead use Copy file API( [^]) Well if you still want to stick with your choice then :- 1. Use CreateProcess use CreateProcess with second parameter is command line argument([^]), where there is a optional structure STARTINFO([^]), having the wShowWindow to show or hide the window. 2. Use ShellExecute([^]) Eg:- NT/2k/XP/2k3
ShellExecute( NULL, "open", "cmd.exe /C \"DEL /f /s /q c:\\check\\*\"", NULL, NULL, SW_HIDE );
Win9x
ShellExecute( NULL, "open", "command.com /C \"DEL /f /s /q c:\\check\\*\"", NULL, NULL, SW_HIDE );
Величие не Бога может быть недооценена.
-
Hi All I am using copy command to join two files. It works fine when I am using this in the command prompt But I want to run this command in the background using vc++. so please tell me how I run this command in the background. copy /b "first file path"+"second file path" "outfilepath"
In addition to what others have mentioned, may be you can take a look at SHFileOperation() API as well. http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx[^]
-
To hide the command window you will have to do a lot more work. You will need to use
CreateProcess
to start the command prompt (Cmd.exe) and specifyingCREATE_NO_WINDOW
in thedwCreationFlags
parameter. If this doesn't work you can set theSTARTF_USESHOWWINDOW
flag in theSTARTUPINFO
structure and set itswShowWindow
member toSW_HIDE
. The copy command will need to be given as parameter to the Cmd.exe. Instead it will be easier to use the file APIs likeCreateFile
andWriteFile
.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Now I tried this char cmdpath[MAX_PATH] ={0}; cmdpath = "copy /b firstfilepath+secondfilepath outfilepath " CreateProcessA("cmd.exe", cmdpath, NULL, NULL, FALSE,NULL DETACHED_PROCESS , NULL, NULL, &sInfo, &pInfo); but this is not joining the file
cmd.exe itself has some command line parameters that you need to specify to execute internal commands.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
I dont think its better to use copy command, instead use Copy file API( [^]) Well if you still want to stick with your choice then :- 1. Use CreateProcess use CreateProcess with second parameter is command line argument([^]), where there is a optional structure STARTINFO([^]), having the wShowWindow to show or hide the window. 2. Use ShellExecute([^]) Eg:- NT/2k/XP/2k3
ShellExecute( NULL, "open", "cmd.exe /C \"DEL /f /s /q c:\\check\\*\"", NULL, NULL, SW_HIDE );
Win9x
ShellExecute( NULL, "open", "command.com /C \"DEL /f /s /q c:\\check\\*\"", NULL, NULL, SW_HIDE );
Величие не Бога может быть недооценена.
-
Thanks for reply can u explain how i use this copy command use in the shellexecute copy /b "firstfile.mp3"+"secondfile.mp3" "outputfile.mp3"
I don't think you can merge MP3 files like that, they both have their own headers describing how is the data encoded (for example, you have 1 mp3 @ 320kbps and 1 mp3 @ 160kbps, what should the file be at the end ?) You will have to convert that to WAV, and then you will be able to copy one WAV at the end of the other and after that reconvert to MP3 (and loosing precision and data in all the conversions). M.
Watched code never compiles.
-
Now I tried this char cmdpath[MAX_PATH] ={0}; cmdpath = "copy /b firstfilepath+secondfilepath outfilepath " CreateProcessA("cmd.exe", cmdpath, NULL, NULL, FALSE,NULL DETACHED_PROCESS , NULL, NULL, &sInfo, &pInfo); but this is not joining the file
raj1576 wrote:
cmdpath = "copy /b firstfilepath+secondfilepath outfilepath "
This will not work. You either need to initialize
cmdpath
with this string literal, or usestrcpy()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
I don't think you can merge MP3 files like that, they both have their own headers describing how is the data encoded (for example, you have 1 mp3 @ 320kbps and 1 mp3 @ 160kbps, what should the file be at the end ?) You will have to convert that to WAV, and then you will be able to copy one WAV at the end of the other and after that reconvert to MP3 (and loosing precision and data in all the conversions). M.
Watched code never compiles.
Maximilien wrote:
I don't think you can merge MP3 files like that, they both have their own headers describing how is the data encoded (for example, you have 1 mp3 @ 320kbps and 1 mp3 @ 160kbps, what should the file be at the end ?)
That's what I thought too, but then he did state, "I am using copy command to join two files. It works fine when I am using this in the command prompt." :confused:
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius