示例#1
0
void __fastcall TFormMain::AutoRunClick(TObject *Sender)
{
	TRegistry *regedit = new TRegistry();
	regedit->RootKey = HKEY_CURRENT_USER;
	regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
	if (this->AutoRun->Checked == true) {
		try {
			regedit->WriteString("ScreenShot", Application->ExeName);
			ShowMessage("Given program will be launched at start computer");
		} catch (Exception *e) {
			ShowMessage("Error: I can not remove autorun");
			DebugOutput(e->Message);
		}
	} else {
		try {
			regedit->DeleteValue("ScreenShot");
			ShowMessage("Autorun was deleted");
		} catch (Exception *e) {
			ShowMessage("Error: i Can't delete a autorun");
            DebugOutput(e->Message);
		}
	}
	regedit->CloseKey();
	regedit->Free();
}
示例#2
0
//---------------------------------------------------------------------------
void __fastcall TFormMain::ExtractParam() {
	if (FileExists(ExtractFilePath(Application->ExeName) + PARAM_FILE) == false)
		return;
	TIniFile *ini = new TIniFile(ExtractFilePath(Application->ExeName)+PARAM_FILE);
	this->EditHost->Text = this->Crypt(ini->ReadString("ftp", "Host", ""));
	this->EditLogin->Text = this->Crypt(ini->ReadString("ftp", "Login", ""));
	this->EditPassword->Text = this->Crypt(ini->ReadString("ftp", "Password", ""));
	this->EditPort->Text = this->Crypt(ini->ReadString("ftp", "Port", ""));
	this->EditPwd->Text = this->Crypt(ini->ReadString("ftp", "Pwd", ""));
	ini->Free();
	TRegistry *regedit = new TRegistry();
	regedit->RootKey = HKEY_CURRENT_USER;
	regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
	if (regedit->ValueExists("ScreenShot") == true)
		this->AutoRun->Checked = true;
	regedit->CloseKey();
	regedit->Free();
}