Thread: Quiet System Calls in C++

  1. #16
    Registered User
    Join Date
    May 2007
    Posts
    6
    Code:
    		string cmdline = "pscp.exe -r -batch -scp -pw \""+m_password+"\" \""+m_file+"\" \""+m_username+"\"@\""+m_host+"\":\""+m_remotedir+"\"";
    
    		STARTUPINFO          si = { sizeof(si) };
    		PROCESS_INFORMATION  pi;
    		char                 *szExe = (char *)cmdline.c_str();
    
    		if(CreateProcess(0, (LPSTR)szExe, 0, 0, FALSE, 0, 0, 0, &si, &pi))
    		{
    			WaitForSingleObject(pi.hProcess, INFINITE);
    			CloseHandle(pi.hProcess);
    			CloseHandle(pi.hThread);
    		}

  2. #17
    Registered User
    Join Date
    May 2007
    Posts
    6
    Thanks for your guys' help.

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > char *szExe = (char *)cmdline.c_str();
    This is dangerous, casting away the const-ness of an object.

    Especially since CreateProcess() indicates that it can be modified.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic system calls help.
    By AmbliKai in forum C Programming
    Replies: 5
    Last Post: 03-21-2008, 07:18 AM
  2. Opinions on custom system build
    By lightatdawn in forum Tech Board
    Replies: 2
    Last Post: 10-18-2005, 04:15 AM
  3. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  4. School Mini-Project on C/C++ (Need Your Help)..
    By EazTerence in forum C++ Programming
    Replies: 4
    Last Post: 09-08-2005, 01:08 AM
  5. System Calls && Variables
    By Okiesmokie in forum C++ Programming
    Replies: 6
    Last Post: 03-06-2002, 09:10 PM