// Create command line
AnsiString CommandIs = "xcopy " + OrgPath + "\\*.* " + BUPath + " /i/s/e/h";
CopyLabel->Caption = "Processing. . .";
Repaint();
//Application->MessageBox(CommandIs.c_str(), "Command", MB_OK); // For testing
STARTUPINFO StartInfo; // name structure
PROCESS_INFORMATION ProcInfo; // name structure
memset(&ProcInfo, 0, sizeof(ProcInfo)); // Set up memory block
memset(&StartInfo, 0 , sizeof(StartInfo)); // Set up memory block
StartInfo.cb = sizeof(StartInfo); // Set structure size
StartInfo.dwFlags = STARTF_USESHOWWINDOW; // Necessary for wShowWindow to work
StartInfo.wShowWindow = SW_HIDE; // Hide window
bool Result = CreateProcess(NULL, CommandIs.c_str(), NULL, NULL, NULL, NULL, NULL, NULL, &StartInfo, &ProcInfo);
if (Result)
{
WaitForSingleObject(ProcInfo.hThread, INFINITE); // wait forever for process to finish
SetFocus(); // Bring back focus
}
else
Application->MessageBox("Could not copy directory.", "Process Error", MB_OK);
// Finish up
CRBUDirectoryListBox->Directory = "\\*.*"; // This forces the directory list box to work better
CRBUDirectoryListBox->Repaint();
DoDirectoriesExist();
Screen->Cursor = crDefault;
Repaint();