CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    16

    [RESOLVED] system() reference plz

    Hi, seek help again ^^ for a complete reference of the function system() because I want manage folders to backup mysql.

    example:
    Code:
    char backup_path [100]="backup";//"c:\\backup"
    if (!folder_exist(backup_path))//check folder
    {
    	//--------------CREATE FOLDER------------------------------------
    	sprintf_s(my_backup,"md %s", my_backup_path);
    	system(backup_md);//create sub-folder backup or c:\backup
    	system("cd backup");//select folder for backup
    	
    	//--------------DUMP DB------------------------------------------
    	GetDlgItemText(hwnd,ID_DB_USE,db_use,80);//db select
    	GetDlgItemText(hwnd,ID_DB_BCK,db_bck,80);//backup name
    	
    	sprintf_s(db_dump,"mysqldump --opt %s > %s.sql",db_use, db_bck);
    	system(db_dump);//dump db
    }
    else
    {
    	/*system("c:");*///dont works
    	system("cd backup");//select folder for backup
    
    	//--------------DUMP DB------------------------------------------
    	GetDlgItemText(hwnd,ID_DB_USE,db_use,80);//db select
    	GetDlgItemText(hwnd,ID_DB_BCK,db_bck,80);//backup name
    	
    	sprintf_s(db_dump,"mysqldump --opt %s > %s.sql",db_use, db_bck);
    	system(db_dump);//dump db
    }
    my dump is fine, but... put in root folder no sub-folder backup or c:\backup
    Im using win32 api+mysql

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: system() reference plz

    Why do you use system?
    To spawn another process you should use CreateProcess API
    Victor Nijegorodov

  3. #3
    Join Date
    May 2012
    Posts
    16

    Thumbs up Re: system() reference plz

    Quote Originally Posted by VictorN View Post
    Why do you use system?
    To spawn another process you should use CreateProcess API
    Because I did not know that xD, when I need, I try to find.

    I resolve:
    Code:
    				SetCurrentDirectory("backup");
    				system(my_backup_query);
    				SetCurrentDirectory("..");//to return parent
    but now I will try with CreateProcess args, thanks a lot for the quick response.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: [RESOLVED] system() reference plz

    Quote Originally Posted by v_nom70 View Post
    Hi, seek help again ^^ for a complete reference of the function system()
    system
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured