"Unit1.cpp" Dosyası
#include <vcl\vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include &shellapi.h>
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SHFILEOPSTRUCT Dosya;
//Silinecek dosyanın tam yolu
//"SilinecekDosya" değişkenine atanıyor.
//Dosyayı daha önceden ana dizininizde oluşturun...
char SilinecekDosya[] = "C:\\Deneme.txt";
//"SHFILEOPSTRUCT" yapısının alt değişkenlerine
//gerekli değerler yükleniyor...
Dosya.pFrom = SilinecekDosya;
Dosya.wFunc = FO_DELETE;
//"Dosya.fFlags" değişkenine atanan değerler arasındani
//"FOF_ALLOWUNDO" kısmını kaldırırsanız dosya doğrudan silinir.
//Kaldırmazsanız recyclebin'e (Çöp Kutusu) atar.
//Dosyayı çöp kutusuna at ve hata mesajlarını
//ve mesaj kutucuklarını gösterme...
Dosya.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI;
//Dosyayı doğrudan silmek için...
//Dosya.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI;
//Eğer hata oluşmuşsa aşağıdaki kod bloğu çalışacaktır.
if (SHFileOperation(&Dosya) != 0)
{
ShowMessage("HATA");
}
}
//---------------------------------------------------------------------------
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
"Unit1.h" Dosyası
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\Dialogs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TLabel *Label1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
PROGRAMIN EKRAN GÖRÜNTÜSÜ
<<< Geri Dön