Quiet System Calls in C++

This is a discussion on Quiet System Calls in C++ within the C++ Programming forums, part of the General Programming Boards category; 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; ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 2 of 2 FirstFirst 12
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, 08:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21