ShellExecute in Konsolenanwendung einbinden



  • Klar ist ShellExecute() auch in einer Konsolenanwendung möglich.

    MfG SideWinder



  • und wie konfiguriere ich das dafür ?



  • Dieser Thread wurde von Moderator/in davie aus dem Forum C++ in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • #include <windows.h>
    #include <shellapi.h>
    
    #pragma comment(lib, "shell32.lib")
    


  • danke aber weis noch jemand ob das ganze auch unter DOS funktioniert oder welche Funktion muss ich da nutzen ?

    vielen Dank



  • was meinst du mit dos?
    win32 konsole, oder 16bit dos?



  • 16 bit DOS möchte gleich im Bootvorgang zwischen 2 Programmen wählen können.



  • 16 bit, no.

    dann exec, spawn, system... (zum bleistift mal im djgpp schaun, mit dem studio kommst du sowieso nicht auf 16 bit runter 😉 )

    shell execute ist eine winapi funktion.



  • kannst du mir vieleicht code posten bitte



  • ich hoffe, du weißt, daß das visual studion kein richtiges dos kann.

    hier ein paar funktionen, die dir unter dos helfen:

    #include <unistd.h>
    
    int execl(const char *path, const char *argv0, ...);
    int execle(const char *path, const char *argv0, ...
               /*, char *const envp[] */);
    int execlp(const char *path, const char *argv0, ...);
    int execlpe(const char *path, const char *argv0, ...
                /*, char *const envp[] */);
    
    int execv(const char *path, char *const argv[]);
    int execve(const char *path, char *const argv[], char *const envp[]);
    int execvp(const char *path, char *const argv[]);
    int execvpe(const char *path, char *const argv[], char *const envp[]);
    
    spawn*
    Syntax
    
    #include <process.h>
    
    int spawnl(int mode, const char *path, const char *argv0, ..., NULL);
    int spawnle(int mode, const char *path, const char *argv0, ...,
                NULL /*, const char **envp */);
    int spawnlp(int mode, const char *path, const char *argv0, ..., NULL);
    int spawnlpe(int mode, const char *path, const char *argv0, ...,
                 NULL /*, const char **envp */);
    
    int spawnv(int mode, const char *path, char *const argv[]);
    int spawnve(int mode, const char *path, char *const argv[],
                char *const envp[]);
    int spawnvp(int mode, const char *path, char *const argv[]);
    int spawnvpe(int mode, const char *path, char *const argv[],
                 char *const envp[]);
    
    Description
    
    These functions run other programs. The path points to the program to run, and 
    may optionally include its extension. These functions will look for a file path
     with the extensions `.com', `.exe', `.bat', and `.btm'; if none are found, 
    neither in the current directory nor along the `PATH', they will look for path 
    itself.
    
    `.com' programs are invoked via the usual DOS calls; DJGPP `.exe' programs are 
    invoked in a way that allows long command lines to be passed; other `.exe' 
    programs are invoked via DOS; `.bat' and `.btm' programs are invoked via the 
    command processor given by the `COMSPEC' environment variable; `.sh', `.ksh' 
    programs and programs with any other extensions that have #! as their first two
     characters are assumed to be Unix-style scripts and are invoked by calling a 
    program whose pathname immediately follows the first two characters. (If the 
    name of that program is a Unix-style pathname, without a drive letter and 
    without an extension, like `/bin/sh', the spawn functions will additionally look
     them up on the `PATH'; this allows to run Unix scripts without editing, if you 
    have a shell installed somewhere along your `PATH'.) Any non-recognizable files 
    will be also invoked via DOS calls.
    
    char *environ[] = {
      "PATH=c:\\dos;c:\\djgpp;c:\\usr\\local\\bin",
      "DJGPP=c:/djgpp",
      0
    };
    
    char *args[] = {
      "gcc",
      "-v",
      "hello.c",
      0
    };
    
    spawnvpe(P_WAIT, "gcc", args, environ);
    


  • dank dir ich probiere mal


Anmelden zum Antworten