DOS befehl einfügen
-
Hey leute ich bin einfach nur noch am verzweifeln ich versuche gerade nen kleines prog zu schreiben das über ne grafische oberfläche den dos/cmd befehl "copy /b beispiel.rar + bild.jpg neues_bild.jpg" (ist der befehl der das .rar archiv "hinter" das bild bringt, kennt ihr bestimmt ) ausführt.
bekomme es einfach nicht gebacken, das wenn ich auf einen button ( im Quellcode heißt er button4) klicke, er das auch in die konsole schreibt.
ich habe soweit alles auch das man sich per grafischer oberfläche den zielort, an dem das neue bild gespeichert werden soll aussuchen kann usw.
schaffe es, wie gesagt, einfach nicht den button dieses ereignis zu zuordnen...
hier noch mein code:#pragma once namespace Rar2JPG_Converter { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; /// <summary> /// Zusammenfassung für Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Konstruktorcode hier hinzufügen. // } protected: /// <summary> /// Verwendete Ressourcen bereinigen. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::TextBox^ textBox3; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::TextBox^ textBox4; protected: private: /// <summary> /// Erforderliche Designervariable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// </summary> void InitializeComponent(void) { this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->textBox4 = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // textBox1 // this->textBox1->Location = System::Drawing::Point(12, 12); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(379, 20); this->textBox1->TabIndex = 0; this->textBox1->Text = L".rar Archiv"; this->textBox1->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged); // // textBox2 // this->textBox2->Location = System::Drawing::Point(12, 38); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(379, 20); this->textBox2->TabIndex = 1; this->textBox2->Text = L"Bild"; this->textBox2->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; // // textBox3 // this->textBox3->Location = System::Drawing::Point(12, 64); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(100, 20); this->textBox3->TabIndex = 2; this->textBox3->Text = L"Speicherort"; this->textBox3->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; this->textBox3->TextChanged += gcnew System::EventHandler(this, &Form1::textBox3_TextChanged); // // button1 // this->button1->Location = System::Drawing::Point(397, 12); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(128, 19); this->button1->TabIndex = 3; this->button1->Text = L"Öffnen"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(397, 39); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(128, 19); this->button2->TabIndex = 4; this->button2->Text = L"Öffnen"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click); // // button3 // this->button3->Location = System::Drawing::Point(118, 64); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(76, 19); this->button3->TabIndex = 5; this->button3->Text = L"Auswählen"; this->button3->UseVisualStyleBackColor = true; this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click); // // button4 // this->button4->Location = System::Drawing::Point(138, 90); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(190, 29); this->button4->TabIndex = 6; this->button4->Text = L"CONVERT!"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click); // // textBox4 // this->textBox4->Location = System::Drawing::Point(209, 63); this->textBox4->Name = L"textBox4"; this->textBox4->Size = System::Drawing::Size(182, 20); this->textBox4->TabIndex = 7; this->textBox4->Text = L"Name der neuen Datei"; this->textBox4->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; this->textBox4->Click += gcnew System::EventHandler(this, &Form1::textBox4_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(537, 144); this->Controls->Add(this->textBox4); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->textBox3); this->Controls->Add(this->textBox2); this->Controls->Add(this->textBox1); this->Name = L"Form1"; this->Text = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { //we use OpenFileDialog to show a file-open dialog box OpenFileDialog CommonDialog; CommonDialog.Title = "Select Map"; CommonDialog.Multiselect = true; CommonDialog.CheckFileExists = true; CommonDialog.Filter = "WinRar-Archiv (*.rar)|*.rar"; CommonDialog.FilterIndex = 1; //if user has clicked on the OK button if(CommonDialog.ShowDialog()== System::Windows::Forms::DialogResult::OK) { textBox1->Text = CommonDialog.FileName; } } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { //we use OpenFileDialog to show a file-open dialog box OpenFileDialog CommonDialog; CommonDialog.Title = "Select Map"; CommonDialog.Multiselect = true; CommonDialog.CheckFileExists = true; CommonDialog.Filter = "JPG-Bilder (*.jpg)|*.jpg"; CommonDialog.FilterIndex = 1; //if user has clicked on the OK button if(CommonDialog.ShowDialog()== System::Windows::Forms::DialogResult::OK) { textBox2->Text = CommonDialog.FileName; } } private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { FolderBrowserDialog CommonDialog; if(CommonDialog.ShowDialog()==System::Windows::Forms::DialogResult::OK) { textBox3->Text = CommonDialog.SelectedPath; } } private: System::Void textBox4_Click(System::Object^ sender, System::EventArgs^ e) { textBox4->Text = ""; } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { String^ rar = textBox1->Text; String^ jpg = textBox2->Text; String^ ziel = textBox3->Text; String^ name = textBox4->Text; String^ befehl = ("copy /b " + rar + " + " + jpg + " " + ziel + name + ".jpg"); } }; }
so jetzt dürfen die profis ran
Thrysta
-
Thrysa schrieb:
so jetzt dürfen die profis ran
ThrystaAber bitte die richtigen. Das sieht mir nach C++/CLI aus.
-
Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C++ (auch C++0x) in das Forum C++/CLI mit .NET verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Die Profis geben diesem Thread erst einmal einen kräftigen Tritt ins CLI-Board (Edit @SeppJ: das wollte ich grad machen)
Ansonsten: Unter C++ kannst du mit
system()
ein externes Programm ausführen lassen, unter .NET gibt es sicherlich auch Alternativen dazu.
-
oh sorry das ich in den falschen bereich gepostet habe...
ja das mit system() hab ich auch gefunden aber des funktioniert hier einfach nicht, da gibt er immer fehler raus...
und ich hab mindestens jetzt schon 1 std gegooglet aber ich werde einfach nicht fündig...
-
Thrysta schrieb:
1 std gegooglet
Eine Standard-Bibliothek ? Stunde abzukürzen benötigt Englischkenntnisse .
-
In .NET benutzt man dazu System::Diagnostics::Process.
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Unter anderem gibts da die (statische) Methode Start(..).
-
EOutOfResources schrieb:
Thrysta schrieb:
1 std gegooglet
Eine Standard-Bibliothek ? Stunde abzukürzen benötigt Englischkenntnisse .
ja okay danke das du mich darauf hinweißt
danke jetzt funktioniert es
thrysta
ps: kann man hier beiträge nicht nachträglich noch einmal editieren?
habe den button gefunden
kann man vll noch den quellcode oben raus machen? habe ihn ja umsonst reingeschrieben...
-
Thrysta schrieb:
ps: kann man hier beiträge nicht nachträglich noch einmal editieren?
habe den button gefunden
kann man vll noch den quellcode oben raus machen? habe ihn ja umsonst reingeschrieben...Ja, als angemeldeter Nutzer darfst du das, aber den Beistrag dort oben hast du vor deiner Anmeldung geschrieben, deshalb mußt du auf einen (hier zuständigen) Moderator warten, der das für dich erledigt.
-
wäre bitte ein moderator so nett und würde den quellcode löschen?
ich kann ihn ja leider nicht löschen weil ich als unregistrierter user gepostet habe
wäre seeeehr nett
thrysta