1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| bool is_readable( const char* file ){
ifstream fichier( file );
return !fichier.fail();
}
private: System::Void but_ok_pass_Click(System::Object^ sender, System::EventArgs^ e) {
String^ file_ini = L""+Application::StartupPath+"//file.ini";
char* path_ini = (char*)(void*)Marshal::StringToHGlobalAnsi(file_ini);
char* old_pass = new char[];
char* old_pass_enter = (char*)(void*)Marshal::StringToHGlobalAnsi(textBox_old_pass->Text);
bool find = false;
if(is_readable(path_ini)){
GetPrivateProfileStringA("CONFIG", "PW", "-1", old_pass, 256, path_ini);
for(int i=0; i<(int)strlen(old_pass);i++)
old_pass[i]=old_pass[i]+15;
}
else
strcpy(old_pass,"Virage01");
if(!strcmp(old_pass,old_pass_enter)){
if(textBox_new_pass->Text==textBox_confirm_pass->Text && textBox_new_pass->Text!="" && textBox_confirm_pass->Text!=""){
String^ new_pass = textBox_new_pass->Text;
char* new_pass2 = (char*)(void*)Marshal::StringToHGlobalAnsi(new_pass);
for(int i=0; i<(int)strlen(new_pass2);i++){
if((new_pass2[i]<58 && new_pass2[i]>47) || (new_pass2[i]>64 && new_pass2[i]<91) || (new_pass2[i]<123 && new_pass2[i]>96))
find = false;
else
find = true;
}
if(find == false){
for(int i=0; i<(int)strlen(new_pass2);i++)
new_pass2[i]=new_pass2[i]-15;
WritePrivateProfileStringA("CONFIG","PW",new_pass2,path_ini);
if(MessageBox::Show(this,"Le mot de pass a été modifié avec succés.","Confirmation",MessageBoxButtons::OK,MessageBoxIcon::Warning) == System::Windows::Forms::DialogResult::OK)
Close();
}
else
MessageBox::Show( "Seul les chiffres et les lettres majuscules ou minuscules sont autorisées.","Caractère interdit",MessageBoxButtons::OK, MessageBoxIcon::Hand);
}
else
MessageBox::Show( "Les mots de passe entrés sont différents ou aucun nouveau mot de passe n'a été entré","Saisie incorrect",MessageBoxButtons::OK, MessageBoxIcon::Hand);
}
else
MessageBox::Show( "Le mot de passe actuel est incorrect","Saisie incorrect",MessageBoxButtons::OK, MessageBoxIcon::Hand);
} |
Partager