Thread: exe files in -c- language

  1. #1
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    Exclamation exe files in -c- language

    hello

    I want well that all hulls helps me has find
    1 - a code that executes a file.exe from a line of command in a c program
    2- a code that invites ms-dos and execute commands


    ------------------------------------------take it easy ---------- .enjoy.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >I want well that all hulls helps me has find
    What the heck is that supposed to mean?

    >a code that executes a file.exe from a line of command in a c program
    Look into system().

    >a code that invites ms-dos and execute commands
    Look into popen().
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    i don't now the methode who proceed

  4. #4
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159

    system(???)==?

    popen(???)==?

    please explain ....!

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    system("file.exe");
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    I guess you were "unable" to find anything, so here's something:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    a MSDN quote for system()
    Execute a command.

    int system( const char *command );

    int _wsystem( const wchar_t *command );

    Routine Required Header Compatibility
    system <process.h> or <stdlib.h> ANSI, Win 95, Win NT
    _wsystem <process.h> or <stdlib.h> or <wchar.h> Win NT


    For additional compatibility information, see Compatibility in the Introduction.

    Libraries

    LIBC.LIB Single thread static library, retail version
    LIBCMT.LIB Multithread static library, retail version
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version


    Return Value

    If command is NULL and the command interpreter is found, the function returns a nonzero value. If the command interpreter is not found, it returns 0 and sets errno to ENOENT. If command is not NULL, system returns the value that is returned by the command interpreter. It returns the value 0 only if the command interpreter returns the value 0. A return value of – 1 indicates an error, and errno is set to one of the following values:

    E2BIG

    Argument list (which is system-dependent) is too big.

    ENOENT

    Command interpreter cannot be found.

    ENOEXEC

    Command-interpreter file has invalid format and is not executable.

    ENOMEM

    Not enough memory is available to execute command; or available memory has been corrupted; or invalid block exists, indicating that process making call was not allocated properly.

    Parameter

    command

    Command to be executed

    Remarks

    The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists.

    You must explicitly flush (using fflush or _flushall) or close any stream before calling system.

    _wsystem is a wide-character version of system; the command argument to _wsystem is a wide-character string. These functions behave identically otherwise.

    Generic-Text Routine Mappings

    TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
    _tsystem system system _wsystem


    Example

    /* SYSTEM.C: This program uses
    * system to TYPE its source file.
    */

    #include <process.h>

    void main( void )
    {
    system( "type system.c" );
    }


    Output

    /* SYSTEM.C: This program uses
    * system to TYPE its source file.
    */
    #include <process.h>
    void main( void )
    {
    system( "type system.c" );
    }


    a MSDN quote for popen()
    Creates a pipe and executes a command.

    FILE *_popen( const char *command, const char *mode );

    FILE *_wpopen( const wchar_t *command, const wchar_t *mode );

    Routine Required Header Compatibility
    _popen <stdio.h> Win 95, Win NT
    _wpopen <stdio.h> or <wchar.h> Win NT


    For additional compatibility information, see Compatibility in the Introduction.

    Libraries

    LIBC.LIB Single thread static library, retail version
    LIBCMT.LIB Multithread static library, retail version
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version


    Return Value

    Each of these functions returns a stream associated with one end of the created pipe. The other end of the pipe is associated with the spawned command’s standard input or standard output. The functions return NULL on an error.

    Parameters

    command

    Command to be executed

    mode

    Mode of returned stream

    Remarks

    The _popen function creates a pipe and asynchronously executes a spawned copy of the command processor with the specified string command. The character string mode specifies the type of access requested, as follows:

    "r"

    The calling process can read the spawned command’s standard output via the returned stream.

    "w"

    The calling process can write to the spawned command’s standard input via the returned stream.

    "b"

    Open in binary mode.

    "t"

    Open in text mode.

    Note The _popen function returns an invalid file handle, if used in a Windows program, that will cause the program to hang indefinitely. _popen works properly in a Console application. To create a Windows application that redirects input and output, read the section "Creating a Child Process with Redirected Input and Output" in the Win32 SDK.

    _wpopen is a wide-character version of _popen; the path argument to _wpopen is a wide-character string. _wpopen and _popen behave identically otherwise.

    Generic-Text Routine Mappings

    TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
    _tpopen _popen _popen _wpopen


    Example

    /* POPEN.C: This program uses _popen and _pclose to receive a
    * stream of text from a system process.
    */

    #include <stdio.h>
    #include <stdlib.h>

    void main( void )
    {

    char psBuffer[128];
    FILE *chkdsk;

    /* Run DIR so that it writes its output to a pipe. Open this
    * pipe with read text attribute so that we can read it
    * like a text file.
    */
    if( (chkdsk = _popen( "dir *.c /on /p", "rt" )) == NULL )
    exit( 1 );

    /* Read pipe until end of file. End of file indicates that
    * CHKDSK closed its standard out (probably meaning it
    * terminated).
    */
    while( !feof( chkdsk ) )
    {
    if( fgets( psBuffer, 128, chkdsk ) != NULL )
    printf( psBuffer );
    }

    /* Close pipe and print return value of CHKDSK. */
    printf( "\nProcess returned %d\n", _pclose( chkdsk ) );
    }


    Output

    Volume in drive C is CDRIVE
    Volume Serial Number is 0E17-1702

    Directory of C:\dolphin\crt\code\pcode

    05/02/94 01:05a 805 perror.c
    05/02/94 01:05a 2,149 pipe.c
    05/02/94 01:05a 882 popen.c
    05/02/94 01:05a 206 pow.c
    05/02/94 01:05a 1,514 printf.c
    05/02/94 01:05a 454 putc.c
    05/02/94 01:05a 162 puts.c
    05/02/94 01:05a 654 putw.c
    8 File(s) 6,826 bytes
    86,597,632 bytes free

    Process returned 0
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  7. #7
    Welcome to the real world
    Join Date
    Feb 2004
    Posts
    50
    I'm waiting for...

    Code:
    hello hulls, do i use a tranzlator

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create Copies of Files
    By Kanshu in forum C++ Programming
    Replies: 13
    Last Post: 05-09-2009, 07:53 AM
  2. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  3. copying files, exe, mp3, etc
    By Blizzarddog in forum C++ Programming
    Replies: 8
    Last Post: 06-17-2003, 08:40 AM
  4. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM