developers-forum.de

Normale Version: [C++] Programme suchen und dann öffnen
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Also diesmal hab ich ein problem mit meinem Mangos starter (erklärung:
ein programm das soll die Mangosd.exe und die Realmd.exe suchen (also wissen wo sie sind) und dann starten (immer überorüfen ob sie noch da sind )
das Funktioniert auch alles super auser das suchen und starten zum suchen benutz ich im mom noch ein anderes Prog (extra) weil es immer ein problem gegeben hatte
also das erste prog zum suchen sieht so aus (ein bisschen lang !!!!

Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <string>
#include <fstream>

using namespace std;

/*
* returns the path to the file, when a first match was found
* returns an empty sring, when no matching filename was found
*/
string searchFile(string File, string inPath) {
    WIN32_FIND_DATA FData;
    HANDLE hSearch = FindFirstFile((inPath + "\\*").c_str(), &FData);

    // return the empty path when we did not find anything
    if (hSearch == INVALID_HANDLE_VALUE)
        return "";

    do {
        // found the file / directory
        if (FData.cFileName == File) {
            return inPath;
        }

        if (FData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) {
            //skip current and parent directory
            if (string(FData.cFileName) != "." && string(FData.cFileName) != "..") {
                //recursive search
                string foundFile = searchFile(
                                    File,
                                    inPath + "\\" + FData.cFileName);

                if (foundFile != "") {
                    return foundFile;
                }
            }
        }
    } while (FindNextFile(hSearch, &FData) != 0);

    // not found
    return "";
}












int main(int argc, char *argv[])
{

//ERSTER TEIL DER SUCHE !!! MANGOSD:EXE

    cout << "Searching for Mangosd.exe..." << endl;

    string found = searchFile(
                    "mangosd.exe",
                    "C:\\");
    
Sleep(500);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
  cout << "\n               100% feritg\n\n";

    //found?
    if (found == "") {
              
        cout << "File not found Traurig" << endl;
        fstream f;
        f.open( "MANGOSD.dat", ios::out );
        f << "Not Found" << endl;
        f.close();
        
    } else {
        cout << found << endl;
        
        
        cout << "\nlog wird erstellt\n";
        Sleep(300);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "\n         100% feritg\n\n";
        fstream f;
        f.open( "MANGOSD.dat", ios::out );
        f << found + "\\mangosd.exe" << endl;
        f.close();
        
        
        
        
      }
    
      ifstream fin("tmp.dat");

      int MAX_LENGTH = 100;
      char line[MAX_LENGTH];
      while( fin.getline(line, MAX_LENGTH) ) {
      cout << "read line: " << line << endl;
      }

    cout << endl;
    
    
    
    
//ZWEITER TEIL DER SUCHE !!!!REALMD:EXE
    
    
    
    cout << "Searching for Realmd.exe..." << endl;

    string found2 = searchFile(
                    "realmd.exe",
                    "C:\\");
    
Sleep(500);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
  cout << "\n               100% feritg\n\n";
  
    //found?
    if (found2 == "") {
              
        cout << "File not found Traurig" << endl;
        fstream f;
        f.open( "REALMD.dat", ios::out );
        f << "Not Found" << endl;
        f.close();
        
    } else {
        cout << found2 << endl;
        
        
        cout << "\nlog wird erstellt\n";
        Sleep(300);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "\n         100% feritg\n\n";
        fstream f;
        f.open( "REALMD.dat", ios::out );
        f << found2 + "\\realmd.exe" << endl;
        f.close();
        
        
        
        

        }
    
      ifstream fin2("tmp.dat");

      char line2[MAX_LENGTH];
      while( fin.getline(line, MAX_LENGTH) ) {
      cout << "read line: " << line2 << endl;
         }
        
        
        
        
         {
      int zahl1;
      

      cout<<"Bitte 1 um Result.txt zu erstellen oder 2 zum beenden mit Enter Bestätigen\n";
      cin>>zahl1;
      if (zahl1 == 1) {
      cout << "sie haben 1 gewählt" << endl;
                if (found + found2 == "") {
                          
                          
                   cout << "\nlog wird erstellt\n";
        Sleep(300);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "\n         100% feritg\n\n";


                   cout << "\n\nBeide wurden nicht gefunden" << endl;
                        fstream f;
                        f.open( "RESULT.log", ios::out );
                        f << "NICHT GEFUNDEN" << endl;
                        f.close();          
                        ;
        
                        } else{
                              
                              
                        cout << "\nlog wird erstellt\n";
        Sleep(300);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);cout << "-";Sleep(25);
cout << "\n         100% feritg\n\n";


                        cout << "\n\nBeide wurden gefunden" << endl;
                        fstream f;
                        f.open( "RESULT.log", ios::out );
                        f << "GEFUNDEN" << endl;
                        f.close();
                        Sleep(2000);}
        
        } else{
         cout << "sie haben 2 gewählt" << endl;
         Sleep(1000);
    
        
        
         }
        
        }
              
    

    
    
    cout << endl;


    
}

wege dene Lade balken

das zweite nimt nun die Zwei dateien "REALMD.dat" und "MANGOSD.dat" und liest sie aus d.h. nimt die daten die drinne stehen und speichert sie in variablen (glaub ich)
mit dene will ich dann meinem programm sagen wo sie liegen und dann soll ers öffnen. da gibts jetzt ein problem er benutzt nicht das was in dene beiden DATS drinne steht (oder sie sind flasch)
erst mal was in den dats steht (kann unterschiedlich sein !!!!

Code:
das ist die MANGOSD.dat
C:\\Mangos\Mangos\mangosd.exe

Code:
das ist die REALMD.dat
C:\\Mangos\Mangos\realmd.exe

das programm zum ausführen sieht so aus

Code:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <process.h>
#include <windows.h>
#include <shellapi.h>
#include <conio.h>
#include <ctype.h>
#include <fstream>

using namespace std;
int main(int argc, char *argv[])
{
    ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    while( fin.getline(line, MAX_LENGTH) ) {
    
}
    ifstream fin2("MANGOSD.dat");
    char line2[MAX_LENGTH];
    while( fin2.getline(line2, MAX_LENGTH) ) {
    
}
cout<<"DIESE exe MUSS IN DEM MANGOS ORDER SEIN !!!!\n";
cout<<"(DA WO REALMD.exe und MANGOSD.exe SIND)\n\n";
Sleep(5000);
cout << "Ralmd.exe liegt in" << line << "\\Realmd.exe" << endl;
cout << "Mangosd.exe liegt in" << line2 << "\\Mangosd.exe" << endl;
Sleep(2000);


cout<<"Realmd.exe wird gestartet\nBitte Warten...\n\n";
Sleep(500);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "                  100% feritg\n";

    ShellExecute
(NULL, "open", "realmd.exe",
NULL, line, SW_SHOW);
Sleep(1000);
cout<<"Realmd.exe wurde erfolgreich gestartet\n\n";
Sleep(5000);


cout<<"Mangosd.exe wird gestartet\nBitte Warten...\n\n";
Sleep(500);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "                  100% feritg\n";

    ShellExecute
(NULL, "open", "mangosd.exe",
NULL, line2, SW_SHOW);
Sleep(1000);
cout<<"Mangosd.exe wurde erfolgreich gestartet\n\n";
Sleep(2000);




if (FindWindow (NULL, line))
{
//existiert
cout<<"Realmd existiert!!\n\n";
Sleep(1000);
}
else
{
//existiert nicht
cout<<"Realmd existiert nicht!!\n";
cout<<"Realmd.exe wird gestartet!!\nBitte Warten...\n\n";
Sleep(1000);
ShellExecute
(NULL, "open", "realmd.exe",
NULL, line, SW_SHOW);
}
Sleep(1000);
            
while(true) {

if (FindWindow (NULL, line2))
{
//existiert
Sleep(1000);
}
else
{
//existiert nicht
cout<<"Realmd existiert nicht!!\n";
cout<<"Realmd.exe wird gestartet!!\nBitte Warten...\n\n";
Sleep(1000);
ShellExecute
(NULL, "open", "realmd.exe",
NULL, line, SW_SHOW);
}
Sleep(1000);
  
if (FindWindow(NULL, line2))
{
//existiert noch

Sleep(1000);
}
else
{
//existiert nicht mehr
cout<<"Mangosd existiert nicht!!\n";
cout<<"Mangosd.exe wird gestartet!!\nBitte Warten...\n\n";
Sleep(1000);
ShellExecute
(NULL, "open", "mangosd.exe",
NULL, line2, SW_SHOW);
}
Sleep(4000);

}}

so da hab ich mal alles ersetzt

so wies da is gehts aber nicht (er öffnet keine programme ) macht eig nichts also er zeigt mir alle couts aber macht nichts
Hi,

in line steht nach dem Auslesen der Datei

Zitat:
C:\\Mangos\Mangos\mangosd.exe


ShellExecute erwartet aber afaik nur den Pfad (ohne dem Dateinamen), also "C:\\Mangos\Mangos\" für line.

Code:
ShellExecute (NULL, "open", "mangos.exe", NULL, line, SW_SHOW);


Du müsstest also in der Datei nur den Pfad speichern und im Programm zur Suche mit FindWindow "mangosd.exe" anhängen.

Das Verketten geht z.B. so:

Code:
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char line[100];    
    cin.getline(line, 100);

    //C-Sring line mit String "\mangosd.exe" verketten
    string s = line + string("\\mangosd.exe");

    //s.c_str() liefert wieder den C-String für FindWindow

    cout << s << endl;
    system("PAUSE");

    return EXIT_SUCCESS;
}


N43

und was mach ich damit im zweiten programm

Code:
int main(int argc, char *argv[])
{
    ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    while( fin.getline(line, MAX_LENGTH) ) {
    
}
    ifstream fin2("MANGOSD.dat");
    char line2[MAX_LENGTH];
    while( fin2.getline(line2, MAX_LENGTH) ) {
    
}

Hallo,

im ersten Programm jeweils nur den Pfad in der Datei speichern. Im zweiten dann wieder einlesen und einen zweiten String erstellen, der Pfad & Dateiname enthält.

Code:
ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    while( fin.getline(line, MAX_LENGTH) ) {
    }

    string file = line + string("\\realmd.exe");


Analog für die zweite Datei. In FindWindow dann file.c_str() einsetzen:

Code:
if (FindWindow (NULL, file.c_str()))



N43

und zum ausführen des programmes ??

Code:
ShellExecute
(NULL, "open", "realmd.exe",
NULL, file, SW_SHOW);
Sleep(1000);
cout<<"Realmd.exe wurde erfolgreich gestartet\n\n";
Sleep(5000);


wenn ich des so wie oben beschrieben mache gibts bei

Code:
NULL, file, SW_SHOW);

einen Fehler

ShellExecute bleibt wie es ist. In line steht dann der Pfad (sofern die Datei richtig angepasst wurde).

Code:
ShellExecute (NULL, "open", "mangos.exe", NULL, line, SW_SHOW);



N43

also ich habe noch folgendes problem ich habe das so gemacht(denk ich)
nur er startet immer noch kein programm

Code:
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <process.h>
#include <windows.h>
#include <shellapi.h>
#include <conio.h>
#include <ctype.h>
#include <fstream>

using namespace std;
int main(int argc, char *argv[])
{
    
    //auslesung der Pfad dateien!!
    //REALMD.exe
    
    ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    while( fin.getline(line, MAX_LENGTH) ) {}
    string file = line + string("\\realmd.exe");
    //ENDE
    //MANGOSD.exe
    
    ifstream fin2("MANGOSD.dat");
    char line2[MAX_LENGTH];
    while( fin2.getline(line2, MAX_LENGTH) ) {}
    string file2 = line2 + string("\\mangosd.exe");
    //ENDE
    
    
    
cout<<"DIESE exe MUSS IN DEM MANGOS ORDER SEIN !!!!\n";
cout<<"(DA WO REALMD.exe und MANGOSD.exe SIND)\n\n";
Sleep(5000);
cout << "Ralmd.exe liegt in" << file << endl;
cout << "Mangosd.exe liegt in" << file2 << endl;
Sleep(2000);


cout<<"Realmd.exe wird gestartet\nBitte Warten...\n\n";
Sleep(500);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "                  100% feritg\n";

    ShellExecute
(NULL, "open", "realmd.exe",
NULL, line, SW_SHOW);
Sleep(1000);
cout<<"Realmd.exe wurde erfolgreich gestartet\n\n";
Sleep(5000);


cout<<"Mangosd.exe wird gestartet\nBitte Warten...\n\n";
Sleep(500);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "-";Sleep(25); cout << "-";Sleep(25);
cout << "                  100% feritg\n";

    ShellExecute
(NULL, "open", "mangosd.exe",
NULL, line2, SW_SHOW);
Sleep(1000);
cout<<"Mangosd.exe wurde erfolgreich gestartet\n\n";
Sleep(2000);



            //nach fenster REALMD.exe suchen!!!
if (FindWindow (NULL, file.c_str()))
{
//existiert
cout<<"Realmd existiert!!\n\n";
Sleep(1000);
}
else
{
//existiert nicht
cout<<"Realmd existiert nicht!!\n";
cout<<"Realmd.exe wird gestartet!!\nBitte Warten...\n\n";
Sleep(1000);
ShellExecute
(NULL, "open", "realmd.exe",
NULL, line, SW_SHOW);
}
Sleep(1000);
            //ENDE!!!!!!
            
            
            
            
            
            //nach Fenster MANGOSD.exe suchen!!!!
if (FindWindow (NULL, file2.c_str()))
{
//existiert
Sleep(1000);
}
else
{
//existiert nicht
cout<<"Mangosd existiert nicht!!\n";
cout<<"Mangosd.exe wird gestartet!!\nBitte Warten...\n\n";
Sleep(1000);
ShellExecute
(NULL, "open", "mangosd.exe",
NULL, line2, SW_SHOW);
}
Sleep(1000);
            //ENDE
  
  


}

ehm das was in den dateien steht is !!

Code:
realmd.exe =
C:\\Mangos\Mangos
mangosd.exe =
C:\\Mangos\Mangos

nochmal er öffnet kein programm !!

ich glaub ja auch das bei

Code:
//auslesung der Pfad dateien!!
    //REALMD.exe
    
    ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    while( fin.getline(line, MAX_LENGTH) ) {}
    string file = line + string("\\realmd.exe");
    //ENDE
    //MANGOSD.exe
    
    ifstream fin2("MANGOSD.dat");
    char line2[MAX_LENGTH];
    while( fin2.getline(line2, MAX_LENGTH) ) {}
    string file2 = line2 + string("\\mangosd.exe");
    //ENDE

die variablen "line" und "line2" garnicht verändert werden sondern "file" und "file2" aus einem "line + dem string realmd.exe " gemacht werden ??!

Abend,

das Problem liegt (zumindest bei mir) beim Auslesen. Er ließt solange Zeilen ein, bis keine mehr da sind. Im letzten Durchlauf in der Schleife füllt er line bzw. line2 mit dem leeren String, da er nur auf EOF (= End of File) trifft.

Um das zu beheben in die MANGOSD.dat und REALMD.dat nur die Zeile mit dem Pfad schreiben und beim Auslesen die Schleife weglassen.

Code:
//auslesung der Pfad dateien!!
    //REALMD.exe
    
    ifstream fin("REALMD.dat");
    int MAX_LENGTH = 100;
    char line[MAX_LENGTH];
    fin.getline(line, MAX_LENGTH);
    string file = line + string("\\realmd.exe");
    //ENDE
    //MANGOSD.exe
    
    ifstream fin2("MANGOSD.dat");
    char line2[MAX_LENGTH];
    fin2.getline(line2, MAX_LENGTH);
    string file2 = line2 + string("\\mangosd.exe");
    //ENDE


Die Dateien sollten dabei so aussehen

MANGOSD.dat schrieb:
C:\\Mangos\Mangos

Analog die REALMD.dat.

Zitat:
die variablen "line" und "line2" garnicht verändert werden sondern "file" und "file2" aus einem "line + dem string realmd.exe " gemacht werden ??!

Jup, genau so isses.


N43

Referenz-URLs