Zapomnialem dodac funkcję która wywołuje ASMa, przepraszam. To jest czytanie z pliku, szyfrowanie wybranym szyfrem ROT13 lub gaderypoluki i zapisywanie do pliku, zalezy mi na liczeniu czasy wykonania danego algorytmu i zapisywaniu gdzies tego. Bardzo prosze o pomoc. Oto cały kod-troche dlugi, przepraszam:
#pragma once
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
namespace projekts {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::ProgressBar^ progressBar1;
private: System::Windows::Forms::SaveFileDialog^ saveFileDialog1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Button());
this->openFileDialog1 = (gcnew System::OpenFileDialog());
this->button2 = (gcnew System::Button());
this->textBox1 = (gcnew System::TextBox());
this->textBox2 = (gcnew System::TextBox());
this->label1 = (gcnew System::Label());
this->label2 = (gcnew System::Label());
this->progressBar1 = (gcnew System::ProgressBar());
this->saveFileDialog1 = (gcnew System::SaveFileDialog());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Point(296, 42);
this->button1->Name = L"button1";
this->button1->Size = System::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"Rot13";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// openFileDialog1
//
this->openFileDialog1->FileName = L"openFileDialog1";
this->openFileDialog1->Title = L"Ścieżka do szyfrowanego pliku";
//
// button2
//
this->button2->Location = System::Point(296, 110);
this->button2->Name = L"button2";
this->button2->Size = System::Size(75, 23);
this->button2->TabIndex = 5;
this->button2->Text = L"Gaderypoluki";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// textBox1
//
this->textBox1->Location = System::Point(13, 44);
this->textBox1->Name = L"textBox1";
this->textBox1->ReadOnly = true;
this->textBox1->Size = System::Size(252, 20);
this->textBox1->TabIndex = 6;
this->textBox1->Text = L"Naciśnij aby wybrać";
this->textBox1->MouseClick += gcnew System::MouseEventHandler(this, &Form1::textBox1_MouseClick);
//
// textBox2
//
this->textBox2->Location = System::Point(13, 112);
this->textBox2->Name = L"textBox2";
this->textBox2->ReadOnly = true;
this->textBox2->Size = System::Size(257, 20);
this->textBox2->TabIndex = 7;
this->textBox2->Text = L"Naciśnij aby wybrać";
this->textBox2->MouseClick += gcnew System::MouseEventHandler(this, &Form1::textBox2_MouseClick);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Point(12, 18);
this->label1->Name = L"label1";
this->label1->Size = System::Size(153, 13);
this->label1->TabIndex = 8;
this->label1->Text = L"Ścieżka do szyfrowanego pliku";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Point(12, 83);
this->label2->Name = L"label2";
this->label2->Size = System::Size(186, 13);
this->label2->TabIndex = 9;
this->label2->Text = L"Ścieżka do zapisu szyfrowanego pliku";
//
// progressBar1
//
this->progressBar1->Location = System::Point(13, 157);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Size(358, 23);
this->progressBar1->TabIndex = 11;
//
// saveFileDialog1
//
this->saveFileDialog1->Title = L"Ścieżka do zapisu szyfrowanego pliku";
//
// Form1
//
this->AutoScaleDimensions = System::SizeF(6, 13);
this->AutoScaleMode = System::Font;
this->ClientSize = System::Size(395, 210);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
System::String^ std2sys(const string s)
{
return gcnew System::String(s.c_str());
}
#pragma endregion
private: System::Void Form1_Load(System::Object sender, System::EventArgs e){}
private: System::Void button1_Click(System::Object sender, System::EventArgs e)
{
int rozmiar=0;
char *nazwa="",*nazwa_zapis="";
fstream plik,plik_zapis;
string linia="";
nazwa = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox1->Text);
nazwa_zapis = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox2->Text);
if(textBox1->Text==textBox2->Text||textBox1->Text==""||textBox2->Text==""||textBox2->Text=="Naciśnij aby wybrać")
{
MessageBox::Show( "Ścieżka do wczytania jest taka sam jak ścieżka do zapisu lub jedna z nich jest źle wypełniona ... MYŚL! lub przestań byc złośliwym :)", "Error");
}
else
{
plik.open(nazwa,ios::in | ios::ate);
if (!plik.fail())
{
rozmiar = plik.tellg();
progressBar1->Maximum=rozmiar;
progressBar1->Minimum=0;
plik.close();
plik_zapis.open(nazwa_zapis,ios::out | ios::binary);
plik_zapis<<"";
plik_zapis.close();
plik.open(nazwa,ios::in | ios::binary);
while(rozmiar>0)
{
getline(plik, linia);
Rot13(&linia[0], linia.length() );
nazwa_zapis = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox2->Text);
plik_zapis.open(nazwa_zapis,ios::out | ios::app | ios::binary);
if (!plik_zapis.fail())
{
plik_zapis<<linia<<endl;
plik_zapis.close();
rozmiar = rozmiar - (linia.length()+1);
progressBar1->Value+=linia.length();
}
else
{
MessageBox::Show( "Problemy z plikiem do którego zapisujesz (sprawdzi ścieżke)", "Error");
rozmiar=0;
}
}
plik.close();
progressBar1->Value=0;
MessageBox::Show( "Zrobione", "Done");
}
else
MessageBox::Show( "Ścieżka do pliku jest nieprawidłowa", "Error");
}
}
private: System::Void button2_Click(System::Object sender, System::EventArgs e)
{
int rozmiar=0;
char *nazwa="",*nazwa_zapis="";
fstream plik,plik_zapis;
string linia="";
nazwa = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox1->Text);
nazwa_zapis = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox2->Text);
if(textBox1->Text==textBox2->Text||textBox1->Text==""||textBox2->Text==""||textBox2->Text=="Naciśnij aby wybrać")
{
MessageBox::Show( "Ścieżka do wczytania jest taka sam jak ścieżka do zapisu lub jedna z nich jest źle wypełniona ... MYŚL! lub przestań byc złośliwym :)", "Error");
}
else
{
plik.open(nazwa,ios::in | ios::ate);
if (!plik.fail())
{
rozmiar = plik.tellg();
progressBar1->Maximum=rozmiar;
progressBar1->Minimum=0;
plik.close();
plik_zapis.open(nazwa_zapis,ios::out | ios::binary);
plik_zapis<<"";
plik_zapis.close();
plik.open(nazwa,ios::in | ios::binary);
while(rozmiar>0)
{
getline(plik, linia);
gaderypoluki(&linia[0], linia.length() );
nazwa_zapis = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox2->Text);
plik_zapis.open(nazwa_zapis,ios::out | ios::app | ios::binary);
if (!plik_zapis.fail())
{
plik_zapis<<linia<<endl;
plik_zapis.close();
rozmiar = rozmiar - (linia.length()+1);
progressBar1->Value+=linia.length();
}
else
{
MessageBox::Show( "Problemy z plikiem do którego zapisujesz (sprawdzi ścieżke)", "Error");
rozmiar=0;
}
}
plik.close();
progressBar1->Value=0;
MessageBox::Show( "Zrobione", "Done");
}
else
MessageBox::Show( "Ścieżka do pliku jest nieprawidłowa", "Error");
}
}
private: System::Void textBox1_MouseClick(System::Object sender, System::MouseEventArgs e)
{
openFileDialog1->Filter = "All files (.)|.| Dokument tekstowy (.txt) |.txt| Word (.doc) |.doc";
openFileDialog1->ShowDialog();
textBox1->Text = openFileDialog1->FileName;
}
private: System::Void textBox2_MouseClick(System::Object sender, System::MouseEventArgs e)
{
saveFileDialog1->Filter = "All files (.)|.| Dokument tekstowy (.txt) |.txt| Word (.doc) |.doc";
saveFileDialog1->ShowDialog();
textBox2->Text = saveFileDialog1->FileName;
}
};
}