Programlama yapalım ve Öğrenelim. - Delphi Eğitim115
  Ana Sayfa
  .NET Eğitim Notları
  Visual C# .NET Örnek Kodları
  VisualBasic.NET Örnek Kodları
  J# Örnekleri
  ASP.NET Örnek Kodları
  Delphi Eğitim
  => Delphi Eğitim1
  => Delphi Eğitim2
  => Delphi Eğitim3
  => Delphi Eğitim4
  => Delphi Eğitim5
  => Delphi Eğitim6
  => Delphi Eğitim7
  => Delphi Eğitim8
  => Delphi Eğitim9
  => Delphi Eğitim10
  => Delphi Eğitim11
  => Delphi Eğitim13
  => Delphi Eğitim14
  => Delphi Eğitim15
  => Delphi Eğitim16
  => Delphi Eğitim17
  => Delphi Eğitim18
  => Delphi Eğitim19
  => Delphi Eğitim20
  => Delphi Eğitim21
  => Delphi Eğitim22
  => Delphi Eğitim23
  => Delphi Eğitim24
  => Delphi Eğitim25
  => Delphi Eğitim26
  => Delphi Eğitim27
  => Delphi Eğitim28
  => Delphi Eğitim29
  => Delphi Eğitim30
  => Delphi Eğtim31
  => Delphi Eğitim32
  => Delphi Eğitim33
  => Delphi Eğitim34
  => Delphi Eğitim35
  => Delphi Eğitim36
  => Delphi Eğitim37
  => Delphi Eğitim38
  => Delphi Eğitim39
  => Delphi Eğitim40
  => Delphi Eğitim41
  => Delphi Eğitim42
  => Delphi Eğitim43
  => Delphi Eğitim44
  => Delphi Eğitim45
  => Delphi Eğitim46
  => Delphi Eğitim47
  => Delphi Eğitim48
  => Delphi Eğitim49
  => Delphi Eğitim50
  => Delphi Eğitim51
  => Delphi Eğitim52
  => Delphi Eğitim53
  => Delphi Eğitim54
  => Delphi Eğitim55
  => Delphi Eğitim56
  => Delphi Eğitim57
  => Delphi Eğitim58
  => Delphi Eğitim59
  => Delphi Eğitim60
  => Delphi Eğitim61
  => Delphi Eğitim62
  => Delphi Eğitim63
  => Delphi Eğitim64
  => Delphi Eğitim65
  => Delphi Eğitim66
  => Delphi Eğitim67
  => Delphi Eğitim68
  => Delphi Eğitim69
  => Delphi Eğitim70
  => Delphi Eğitim71
  => Delphi Eğitim72
  => Delphi Eğitim73
  => Delphi Eğitim74
  => Delphi Eğitim75
  => Delphi Eğitim76
  => Delphi Eğitim77
  => Delphi Eğitim78
  => Delphi Eğitim79
  => Delphi Eğitim80
  => Delphi Eğitim81
  => Delphi Eğitim82
  => Delphi Eğitim83
  => Delphi Eğitim84
  => Delphi Eğitim85
  => Delphi Eğitim86
  => Delphi Eğitim87
  => Delphi Eğitim88
  => Delphi Eğitim89
  => Delphi Eğitim90
  => Delphi Eğitim91
  => Delphi Eğitim92
  => Delphi Eğitim93
  => Delphi Eğitim94
  => Delphi Eğitim95
  => Delphi Eğitim96
  => Delphi Eğitim97
  => Delphi Eğitim98
  => Delphi Eğitim99
  => Delphi Eğitim100
  => Delphi Eğitim101
  => Delphi Eğitim102
  => Delphi Eğitim103
  => Delphi Eğitim104
  => Delphi Eğitim105
  => Delphi Eğitim106
  => Delphi Eğitim107
  => Delphi Eğitim108
  => Delphi Eğitim109
  => Delphi Eğitim110
  => Delphi Eğitim111
  => Delphi Eğitim112
  => Delphi Eğitim113
  => Delphi Eğitim114
  => Delphi Eğitim115
  => Delphi Eğitim116
  => Delphi Eğitim117
  => Delphi Eğitim118
  => Delphi Eğitim119
  => Delphi Eğitim120
  => Delphi Eğitim121
  => Delphi Eğitim122
  => Delphi Eğitim123
  => Delphi Eğitim124
  => Delphi Eğitim125
  => Delphi Eğitim126
  => Delphi Eğitim127
  => Delphi Eğitim128
  => Delphi Eğitim129
  => Delphi Eğitim130
  => Delphi Eğitim131
  => Delphi Eğitim132
  => Delphi Eğitim133
  => Delphi Eğitim134
  => Delphi Eğitim135
  => Delphi Eğitim136
  => Delphi Eğitim137
  => Delphi Eğitim138
  => Delphi Eğitim139
  => Delphi Eğitim140
  => Delphi Eğitim141
  => Delphi Eğitim142
  => Delphi Eğitim143
  => Delphi Eğitim144
  => Delphi Eğitim145
  => Delphi Eğitim146
  => Delphi eğitim147
  => Delphi Eğitim148
  => Delphi Eğitim149
  => Delphi Eğitim150
  => Delphi Eğitim151
  => Delphi Eğitim152
  => Delphi Eğitim153
  => Delphi Eğitim154
  => Delphi Eğitim155
  => Delphi Eğitim156
  => Delphi Eğitim157
  => Delphi Eğitim158
  => Delphi Eğitim159
  => Delphi Eğitim160
  => Delphi Eğitim161
  => Delphi Eğitim162
  => Delphi Eğitim164
  => Delphi Eğitim165
  => Delphi Eğitim166
  => Delphi Eğitim167
  => Delphi Eğitim168
  => Delphi Eğitim169
  => Delphi Eğitim170
  => Delphi Eğitim171
  => Delphi Eğitim172
  => Delphi Eğitim173
  => Delphi Eğitim174
  => Delphi Eğitim175
  => Delphi Eğitim176
  => Delphi Eğitim177
  => Delphi Eğitim178
  => Delphi Eğitim179
  => Delphi Eğitim180
  => Delphi Eğitim181
  => Delphi Eğitim182
  => Delphi Eğitim183
  => Delphi Eğitim184
  => Delphi Eğitim185
  => Delphi Eğitim186
  => Delphi Eğitim187
  => Delphi Eğitim188
  => Delphi Eğitim189
  => Delphi Eğitim190
  => Delphi Eğitim191
  => Delphi Eğitim192
  => Delphi Eğitim193
  => Delphi Eğitim194
  => Delphi Eğitim195
  => Delphi Eğitim196
  => Delphi Eğitim197
  => Delphi Eğitim198
  => Delphi Eğitim199
  => Delphi Eğitim200
  => Delphi Eğitim201
  => Delphi Eğitim202
  => Delphi Eğitim203
  => Delphi Eğitim204
  => Delphi Eğitim205
  => Delphi Eğitim206
  => Delphi Eğitim207
  => Delphi Eğitim208
  => Delphi Eğitim209
  => Delphi Eğitim210
  => Delphi Eğitim211
  => Delphi Eğitim212
  => Delphi Eğitim213
  => Delphi Eğitim214
  => Delphi Eğitim215
  => Delphi Eğitim216
  => Delphi Eğitim217
  => Delphi Eğitim218
  => Delphi Eğitim219
  => Delphi Eğitim220
  => Delphi Eğitim221
  => Delphi Eğitim222
  => Delphi Eğitim223
  => Delphi Eğitim224
  => Delphi Eğitim225
  => Delphi Eğitim226
  => Delphi Eğitim227
  => Delphi Eğitim228
  => Delphi Eğitim229
  => Delphi Eğitim230
  => Delphi Eğitim231
  => Delphi Eğitim232
  => Delphi Eğitim233
  => Delphi Eğitim234
  => Delphi Eğitim235
  => Delphi Eğitim236
  => Delphi Eğitim237
  => Delphi Eğitim238
  => Delphi Eğitim239
  => Delphi Eğitim240
  => Delphi Eğitim241
  => Delphi Eğitim242
  İletişim

Güç kontrolü

unit PowerControl;

 

interface

 

uses WinTypes, WinProcs, Messages, SysUtils, Classes, Controls,

     Forms, Graphics, MMSystem;

 

type

   TAction = (actLogOFF,actShutDown,actReBoot,actForce,actPowerOFF,

actForceIfHung,actMonitorOFF,actMonitorON,actCDEject,actCDUnEject);

 

type

  TPowerControl = class(TComponent)

    private

        FAction : TAction;

        procedure SetAction(Value : TAction);

    protected

    public

        function Execute : Boolean;

    published

        property Action : TAction read FAction write SetAction;

  end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

     RegisterComponents('K2', [TPowerControl]);

end;

 

procedure TPowerControl.SetAction(Value : TAction);

begin

     FAction := Value;

end;

 

function TPowerControl.Execute : Boolean;

begin

    with (Owner as TForm) do

       case FAction of

         actLogOff: ExitWindowsEx(EWX_LOGOFF,1);

         actShutDown: ExitWindowsEx(EWX_SHUTDOWN,1);

         actReBoot: ExitWindowsEx(EWX_REBOOT,1);

         actForce: ExitWindowsEx(EWX_FORCE,1);

         actPowerOff: ExitWindowsEx(EWX_POWEROFF,1);

         actForceIfHung: ExitWindowsEx(EWX_FORCEIFHUNG,1);

         actMonitorOFF: SendMessage(Application.Handle,

                        WM_SYSCOMMAND, SC_MONITORPOWER, 0);

         actMonitorON: SendMessage(Application.Handle, WM_SYSCOMMAND,

                       SC_MONITORPOWER, -1);

         actCDEject: mciSendstring('SET CDAUDIO DOOR OPEN

                     WAIT',nil,0, Handle);

         actCDUnEject: mciSendstring('SET CDAUDIO DOOR CLOSED

                       WAIT',nil,0, Handle);

       end; {Case}

    Result := True;

end;

 

end.

 

Delphi - .....................................

 

Güç kontrolü

unit PowerControl;

 

interface

 

uses WinTypes, WinProcs, Messages, SysUtils, Classes, Controls,

     Forms, Graphics, MMSystem;

 

type

   TAction = (actLogOFF,actShutDown,actReBoot,actForce,actPowerOFF,

actForceIfHung,actMonitorOFF,actMonitorON,actCDEject,actCDUnEject);

 

type

  TPowerControl = class(TComponent)

    private

        FAction : TAction;

        procedure SetAction(Value : TAction);

    protected

    public

        function Execute : Boolean;

    published

        property Action : TAction read FAction write SetAction;

  end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

     RegisterComponents('K2', [TPowerControl]);

end;

 

procedure TPowerControl.SetAction(Value : TAction);

begin

     FAction := Value;

end;

 

function TPowerControl.Execute : Boolean;

begin

    with (Owner as TForm) do

       case FAction of

         actLogOff: ExitWindowsEx(EWX_LOGOFF,1);

         actShutDown: ExitWindowsEx(EWX_SHUTDOWN,1);

         actReBoot: ExitWindowsEx(EWX_REBOOT,1);

         actForce: ExitWindowsEx(EWX_FORCE,1);

         actPowerOff: ExitWindowsEx(EWX_POWEROFF,1);

         actForceIfHung: ExitWindowsEx(EWX_FORCEIFHUNG,1);

         actMonitorOFF: SendMessage(Application.Handle,

                        WM_SYSCOMMAND, SC_MONITORPOWER, 0);

         actMonitorON: SendMessage(Application.Handle, WM_SYSCOMMAND,

                       SC_MONITORPOWER, -1);

         actCDEject: mciSendstring('SET CDAUDIO DOOR OPEN

                     WAIT',nil,0, Handle);

         actCDUnEject: mciSendstring('SET CDAUDIO DOOR CLOSED

                       WAIT',nil,0, Handle);

       end; {Case}

    Result := True;

end;

 

end.

 

Delphi - .....................................

 

printer eklemek

unit unit_AddPrinter;

 

    interface

 

    function AddAPrinter(PrinterName, PortName, DriverName, PrintProcessor: string): boolean;

 

    implementation

 

    uses

      SysUtils,

      WinSpool,

      Windows;

 

    function AddAPrinter(PrinterName, PortName, DriverName, PrintProcessor: string):     boolean;

    var

      pName: PChar;

      Level: DWORD;

      pPrinter: PPrinterInfo2;

    begin

 

      pName := nil;

      Level := 2;

      New(pPrinter);

      pPrinter^.pServerName := nil;

      pPrinter^.pShareName := nil;

      pPrinter^.pComment := nil;

      pPrinter^.pLocation := nil;

      pPrinter^.pDevMode := nil;

      pPrinter^.pSepFile := nil;

      pPrinter^.pDatatype := nil;

      pPrinter^.pParameters := nil;

      pPrinter^.pSecurityDescriptor := nil;

      pPrinter^.Attributes := 0;

      pPrinter^.Priority := 0;

      pPrinter^.DefaultPriority := 0;

      pPrinter^.StartTime := 0;

      pPrinter^.UntilTime := 0;

      pPrinter^.Status := 0;

      pPrinter^.cJobs := 0;

      pPrinter^.AveragePPM :=0;

 

      pPrinter^.pPrinterName := PCHAR(PrinterName);

      pPrinter^.pPortName := PCHAR(PortName);

      pPrinter^.pDriverName := PCHAR(DriverName);

      pPrinter^.pPrintProcessor := PCHAR(PrintProcessor);

 

      if AddPrinter(pName, Level, pPrinter) <> 0 then

        Result := true

      else begin

        // ShowMessage(inttostr(GetlastError));

        Result := false;

      end;

 

    end;

 

end.

 

Delphi - .....................................

 

printer eklemek

unit unit_AddPrinter;

 

    interface

 

    function AddAPrinter(PrinterName, PortName, DriverName, PrintProcessor: string): boolean;

 

    implementation

 

    uses

      SysUtils,

      WinSpool,

      Windows;

 

    function AddAPrinter(PrinterName, PortName, DriverName, PrintProcessor: string):     boolean;

    var

      pName: PChar;

      Level: DWORD;

      pPrinter: PPrinterInfo2;

    begin

 

      pName := nil;

      Level := 2;

      New(pPrinter);

      pPrinter^.pServerName := nil;

      pPrinter^.pShareName := nil;

      pPrinter^.pComment := nil;

      pPrinter^.pLocation := nil;

      pPrinter^.pDevMode := nil;

      pPrinter^.pSepFile := nil;

      pPrinter^.pDatatype := nil;

      pPrinter^.pParameters := nil;

      pPrinter^.pSecurityDescriptor := nil;

      pPrinter^.Attributes := 0;

      pPrinter^.Priority := 0;

      pPrinter^.DefaultPriority := 0;

      pPrinter^.StartTime := 0;

      pPrinter^.UntilTime := 0;

      pPrinter^.Status := 0;

      pPrinter^.cJobs := 0;

      pPrinter^.AveragePPM :=0;

 

      pPrinter^.pPrinterName := PCHAR(PrinterName);

      pPrinter^.pPortName := PCHAR(PortName);

      pPrinter^.pDriverName := PCHAR(DriverName);

      pPrinter^.pPrintProcessor := PCHAR(PrintProcessor);

 

      if AddPrinter(pName, Level, pPrinter) <> 0 then

        Result := true

      else begin

        // ShowMessage(inttostr(GetlastError));

        Result := false;

      end;

 

    end;

 

end.

 

Delphi - .....................................

 

Klavye dilinin öğrenilmesi ve değiştirilmesi

procedure GetKLList(List: TStrings);

var

  AList : array [0..9] of Hkl;

  AklName: array [0..255] of Char;

  i: Longint;

begin

  List.Clear;

  for i := 0 to GetKeyboardLayoutList(SizeOf(AList), AList) - 1 do

    begin

      GetLocaleInfo(LoWord(AList[i]), LOCALE_SLANGUAGE, AklName, SizeOf(AklName));

      List.AddObject(AklName, Pointer(AList[i]));

    end;

end;

 

 

procedure TForm1.FormCreate(Sender: TObject);

begin

GetKLList(ListBox1.Items);

end;

 

procedure TForm1.ListBox1Click(Sender: TObject);

begin

with Sender as TListBox do

    ActivateKeyboardLayout(Hkl(Items.Objects[ItemIndex]), 0);

 

end;

 

Delphi - .....................................

 

Klavye dilinin öğrenilmesi ve değiştirilmesi

procedure GetKLList(List: TStrings);

var

  AList : array [0..9] of Hkl;

  AklName: array [0..255] of Char;

  i: Longint;

begin

  List.Clear;

  for i := 0 to GetKeyboardLayoutList(SizeOf(AList), AList) - 1 do

    begin

      GetLocaleInfo(LoWord(AList[i]), LOCALE_SLANGUAGE, AklName, SizeOf(AklName));

      List.AddObject(AklName, Pointer(AList[i]));

    end;

end;

 

 

procedure TForm1.FormCreate(Sender: TObject);

begin

GetKLList(ListBox1.Items);

end;

 

procedure TForm1.ListBox1Click(Sender: TObject);

begin

with Sender as TListBox do

    ActivateKeyboardLayout(Hkl(Items.Objects[ItemIndex]), 0);

 

end;

 

Delphi - .....................................

 

SQL ile çift kayıtların silinmesi

Deleting Duplicate Records

Regular Columnist : Sureshkumar Ramakrishnan

Posted: 03/10/2006

(Original Publication Date: 12/20/2004)

 

 The table below shows the data present in the Employeetable.

 

id    Name Salary     

1     Ram   1000

1     Ram   1000

2     Joe   2000

2     Joe   1000

3     Mary 1000

4     Julie       5000

2     Joe   1000

1     Ram   1000

 

The following script deletes the duplicates from Employeetable. If there are duplicate records then the script will get a count of the duplicate records and will then delete the records till the count is 1.

 

/*******************************************************************/

/* Script for deletion of Duplicate record from the Employee Table */

Declare @id int,

        @name varchar (50),

        @cnt int,

        @salary numeric

 

Declare getallrecords cursor local static For

 Select count (1), id, name, salary

   from employee (nolock)

   group by id, name,salary having count(1)>1

 

Open getallrecords

 

Fetch next from getallrecords into @cnt,@id,@name,@salary

--Cursor to check with all other records

While @@fetch_status=0

 Begin

  Set @cnt= @cnt-1

  Set rowcount @cnt

 

  -- Deleting the duplicate records. Observe that all fields are mentioned at the where condition

  Delete from employee where id=@id and name=@name

  and salary=@salary

 

  Set rowcount 0

 

  Fetch next from getallrecords into @cnt,@id,@name,@salary

 End

 

Close getallrecords

Deallocate getallrecords

 

*******************************************************************

 

The logic of the script is pretty simple; the select query retrieves all the records that are duplicates i.e. having Count greater than one. The result set is retrieved by opening a local cursor which fetches one row at a time.

 

Note here that the Count column is a part of the select query; this is used to identify the no of duplicate rows in the result set.

 

The row count has been set to (Value obtained from the Count Column 1). SQL Server uses rowcount to stop processing the query after the specified numbers of rows are returned. The delete statement is executed only to delete the rows set by the Set rowcount command. Once the records have been deleted, the rowcount of SQL server is reset to the default value of 0.

 

For more details on row count visit (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_0bjo.asp)

 

After the above script is executed the data in the Employeetable is as shown below and note that there are no duplicates anymore:

id    Name Salary     

1     Ram   1000

2     Joe   1000

2     Joe   2000

3     Mary 1000

4     Julie       5000

 

In the above example duplicate records were deleted at a row level, as we had considered all the columns in the select query. By customizing the script you can also delete duplicate records at a column level. This Query can be extremely beneficial and time saving for data cleansing during Data Migration.

 

Delphi - .....................................

 

SQL ile çift kayıtların silinmesi

Deleting Duplicate Records

Regular Columnist : Sureshkumar Ramakrishnan

Posted: 03/10/2006

(Original Publication Date: 12/20/2004)

 

 The table below shows the data present in the Employeetable.

 

id    Name Salary     

1     Ram   1000

1     Ram   1000

2     Joe   2000

2     Joe   1000

3     Mary 1000

4     Julie       5000

2     Joe   1000

1     Ram   1000

 

The following script deletes the duplicates from Employeetable. If there are duplicate records then the script will get a count of the duplicate records and will then delete the records till the count is 1.

 

/*******************************************************************/

/* Script for deletion of Duplicate record from the Employee Table */

Declare @id int,

        @name varchar (50),

        @cnt int,

        @salary numeric

 

Declare getallrecords cursor local static For

 Select count (1), id, name, salary

   from employee (nolock)

   group by id, name,salary having count(1)>1

 

Open getallrecords

 

Fetch next from getallrecords into @cnt,@id,@name,@salary

--Cursor to check with all other records

While @@fetch_status=0

 Begin

  Set @cnt= @cnt-1

  Set rowcount @cnt

 

  -- Deleting the duplicate records. Observe that all fields are mentioned at the where condition

  Delete from employee where id=@id and name=@name

  and salary=@salary

 

  Set rowcount 0

 

  Fetch next from getallrecords into @cnt,@id,@name,@salary

 End

 

Close getallrecords

Deallocate getallrecords

 

*******************************************************************

 

The logic of the script is pretty simple; the select query retrieves all the records that are duplicates i.e. having Count greater than one. The result set is retrieved by opening a local cursor which fetches one row at a time.

 

Note here that the Count column is a part of the select query; this is used to identify the no of duplicate rows in the result set.

 

The row count has been set to (Value obtained from the Count Column 1). SQL Server uses rowcount to stop processing the query after the specified numbers of rows are returned. The delete statement is executed only to delete the rows set by the Set rowcount command. Once the records have been deleted, the rowcount of SQL server is reset to the default value of 0.

 

For more details on row count visit (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_0bjo.asp)

 

After the above script is executed the data in the Employeetable is as shown below and note that there are no duplicates anymore:

id    Name Salary     

1     Ram   1000

2     Joe   1000

2     Joe   2000

3     Mary 1000

4     Julie       5000

 

In the above example duplicate records were deleted at a row level, as we had considered all the columns in the select query. By customizing the script you can also delete duplicate records at a column level. This Query can be extremely beneficial and time saving for data cleansing during Data Migration.

 

Delphi - .....................................

 

CSV text dosyadan veri alma

CSV dosyadan database a veri çekme hakkında kod arıyorum.

 

Delphi - .....................................

 

CSV text dosyadan veri alma

CSV dosyadan database a veri çekme hakkında kod arıyorum.

 

Delphi - .....................................

 

Borsa Hisse Bilgileri

Imkb hisse senedi fiyatlarını alabileceğim bir kod arıyorum.

İnsanların borsadaki hisselerini canlı takip edebilecekleri  bir borsa bandı yapmaya çalışıyorum

Lütfen yardım edin. Tek bir hissenin fiyatını bir alabilsem....

 

Delphi - .....................................

 

Borsa Hisse Bilgileri

Imkb hisse senedi fiyatlarını alabileceğim bir kod arıyorum.

İnsanların borsadaki hisselerini canlı takip edebilecekleri  bir borsa bandı yapmaya çalışıyorum

Lütfen yardım edin. Tek bir hissenin fiyatını bir alabilsem....

 

Delphi - .....................................

 

Klasör ve alt klasörlerde dosya aramak ve bulunanlari bir listeye atmak

Klasör ve alt klasörlerde dosya aramak ve bulunanlari bir listeye atmak

 

{

Form1'in üzerindeki Memo1'e bulunan dosyalari ekler.

Not: Kod recursion kullanmakta. Cok fazla (Binlerce)

dosya bulundugunda Stack Overflow hatasi verebilir

}

 

 

procedure TForm1.FindFiles(StartDir, FileMask: string);

var

  SR: TSearchRec;

  DirList: TStringList;

  IsFound: Boolean;

  i: integer;

begin

  if StartDir[length(StartDir)] <> '' then

    StartDir := StartDir + '';

 

 

  IsFound :=

    FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0;

  while IsFound do begin

    Memo1.Lines.Add(StartDir + SR.Name);

    IsFound := FindNext(SR) = 0;

  end;

  FindClose(SR);

 

  DirList := TStringList.Create;

  IsFound := FindFirst(StartDir+'*.*', faAnyFile, SR) = 0;

  while IsFound do begin

    if ((SR.Attr and faDirectory) <> 0) and

         (SR.Name[1] <> '.') then

      DirList.Add(StartDir + SR.Name);

    IsFound := FindNext(SR) = 0;

  end;

  FindClose(SR);

 

  for i := 0 to DirList.Count-1 do

    FindFiles(DirList[i], FileMask);

  DirList.Free;

end;

 

// Kullanimi:

FindFiles('C:windows', '*.txt');

 

***************************

 

Delphi - .....................................

 

Klasör ve alt klasörlerde dosya aramak ve bulunanlari bir listeye atmak

Klasör ve alt klasörlerde dosya aramak ve bulunanlari bir listeye atmak

 

{

Form1'in üzerindeki Memo1'e bulunan dosyalari ekler.

Not: Kod recursion kullanmakta. Cok fazla (Binlerce)

dosya bulundugunda Stack Overflow hatasi verebilir

}

 

 

procedure TForm1.FindFiles(StartDir, FileMask: string);

var

  SR: TSearchRec;

  DirList: TStringList;

  IsFound: Boolean;

  i: integer;

begin

  if StartDir[length(StartDir)] <> '' then

    StartDir := StartDir + '';

 

 

  IsFound :=

    FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0;

  while IsFound do begin

    Memo1.Lines.Add(StartDir + SR.Name);

    IsFound := FindNext(SR) = 0;

  end;

  FindClose(SR);

 

  DirList := TStringList.Create;

  IsFound := FindFirst(StartDir+'*.*', faAnyFile, SR) = 0;

  while IsFound do begin

    if ((SR.Attr and faDirectory) <> 0) and

         (SR.Name[1] <> '.') then

      DirList.Add(StartDir + SR.Name);

    IsFound := FindNext(SR) = 0;

  end;

  FindClose(SR);

 

  for i := 0 to DirList.Count-1 do

    FindFiles(DirList[i], FileMask);

  DirList.Free;

end;

 

// Kullanimi:

FindFiles('C:windows', '*.txt');

 

***************************

 

Delphi - .....................................

 

Bir klasörün toplam boyutu nasil alinir ?

Bir klasörün toplam boyutu nasil alinir ?

 

function GetDirectorySize(const ADirectory: string): Integer;

var

  Dir:  TSearchRec;

  Ret:  integer;

  Path: string;

begin

  Result := 0;

  Path   := ExtractFilePath(ADirectory);

  Ret    := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);

 

  if Ret <> NO_ERROR then

    exit;

 

  try

    while ret=NO_ERROR do

    begin

      inc(Result, Dir.Size);

      if (Dir.Attr in [faDirectory]) and (Dir.Name[1] <> '.') then

         Inc(Result, GetDirectorySize(Path + Dir.Name + '*.*'));

      Ret := Sysutils.FindNext(Dir);

    end;

  finally

    Sysutils.FindClose(Dir);

  end;

end;

 

//Kullanimi:

procedure TForm1.Button1Click(Sender: TObject);

begin

  label1.caption := Format('Boyut: %d bytes', [GetDirectorySize('C:Windows')]);

end;

 

 

*************************

 

Delphi - .....................................

 

Bir klasörün toplam boyutu nasil alinir ?

Bir klasörün toplam boyutu nasil alinir ?

 

function GetDirectorySize(const ADirectory: string): Integer;

var

  Dir:  TSearchRec;

  Ret:  integer;

  Path: string;

begin

  Result := 0;

  Path   := ExtractFilePath(ADirectory);

  Ret    := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);

 

  if Ret <> NO_ERROR then

    exit;

 

  try

    while ret=NO_ERROR do

    begin

      inc(Result, Dir.Size);

      if (Dir.Attr in [faDirectory]) and (Dir.Name[1] <> '.') then

         Inc(Result, GetDirectorySize(Path + Dir.Name + '*.*'));

      Ret := Sysutils.FindNext(Dir);

    end;

  finally

    Sysutils.FindClose(Dir);

  end;

end;

 

//Kullanimi:

procedure TForm1.Button1Click(Sender: TObject);

begin

  label1.caption := Format('Boyut: %d bytes', [GetDirectorySize('C:Windows')]);

end;

 

 

*************************

 

Delphi - .....................................

 

VeriTabanindan Excele Aktarim.

VeriTabanindan Excele Aktarim.

 

{Form üzerine ole serverla baglanti kurmak icin "servers" bilesenlerinden "ExcelApplication"

nesnesini eklemeniz gerekir.

IRange.AutoFormat(6,Null,Null,Null,Null,Null,Null);

Bu Satirdaki Rakami 1-15 arasinada Degistirerek degisik Formatlar elde edebilirsiniz}

 

 

procedure TForm1.Button1Click(Sender: TObject);

var IRange  : Excel97.Range;

    i,Row : integer;

 

begin

 

   if not ExcelApplication1.Visible[0]  then //excel acikmi

    begin

     excelApplication1.Visible[0]:= True; //acik degilse ac

     excelApplication1.Workbooks.Add(NULL,0); //yeni calisma kitabi olustur

    end

   else //excel aciksa  yeni calisma sayfasi ekle

        excelApplication1.Sheets.Add(Null,null,null,null,1);

 

    // Alan Basliklarini aktar

    IRange := excelApplication1.ActiveCell;

    for i := 0 to Table1.Fields.count-1 do

    begin

        IRange.Value := Table1.Fields[i].DisplayLabel;

        IRange := IRange.Next;

    end;

 

     // Kayitlari Aktar

 

    Table1.DisableControls;

  try

      Table1.First;

      Row :=2;

      while not Table1.Eof do

      begin

          IRange := ExcelApplication1.Range['A'+IntToStr(Row),'A'+IntToStr(Row)];

          for i := 0 to Table1.Fields.Count-1 do

          begin

              IRange.Value := Table1.Fields[i].Value;

              IRange := IRange.Next;

          end;

          Table1.Next;

          Inc(Row);

      end;

 

 

  finally

 

      Table1.EnableControls;

  end;

   // Auto format

 

   IRange:= ExcelApplication1.Range['A1','D'+IntToStr(Row-1)];

   IRange.AutoFormat(6,Null,Null,Null,Null,Null,Null);

end;

 

**************************

 

Delphi - .....................................

 

VeriTabanindan Excele Aktarim.

VeriTabanindan Excele Aktarim.

 

{Form üzerine ole serverla baglanti kurmak icin "servers" bilesenlerinden "ExcelApplication"

nesnesini eklemeniz gerekir.

IRange.AutoFormat(6,Null,Null,Null,Null,Null,Null);

Bu Satirdaki Rakami 1-15 arasinada Degistirerek degisik Formatlar elde edebilirsiniz}

 

 

procedure TForm1.Button1Click(Sender: TObject);

var IRange  : Excel97.Range;

    i,Row : integer;

 

begin

 

   if not ExcelApplication1.Visible[0]  then //excel acikmi

    begin

     excelApplication1.Visible[0]:= True; //acik degilse ac

     excelApplication1.Workbooks.Add(NULL,0); //yeni calisma kitabi olustur

    end

   else //excel aciksa  yeni calisma sayfasi ekle

        excelApplication1.Sheets.Add(Null,null,null,null,1);

 

    // Alan Basliklarini aktar

    IRange := excelApplication1.ActiveCell;

    for i := 0 to Table1.Fields.count-1 do

    begin

        IRange.Value := Table1.Fields[i].DisplayLabel;

        IRange := IRange.Next;

    end;

 

     // Kayitlari Aktar

 

    Table1.DisableControls;

  try

      Table1.First;

      Row :=2;

      while not Table1.Eof do

      begin

          IRange := ExcelApplication1.Range['A'+IntToStr(Row),'A'+IntToStr(Row)];

          for i := 0 to Table1.Fields.Count-1 do

          begin

              IRange.Value := Table1.Fields[i].Value;

              IRange := IRange.Next;

          end;

          Table1.Next;

          Inc(Row);

      end;

 

 

  finally

 

      Table1.EnableControls;

  end;

   // Auto format

 

   IRange:= ExcelApplication1.Range['A1','D'+IntToStr(Row-1)];

   IRange.AutoFormat(6,Null,Null,Null,Null,Null,Null);

end;

 

**************************

 

Delphi - .....................................

 

Key Kodları

Key Kodlari

 

{ Virtual Keys, Standard Set }

VK_LBUTTON = 1;

VK_RBUTTON = 2;

VK_CANCEL = 3;

VK_MBUTTON = 4; { NOT contiguous with L & RBUTTON }

VK_BACK = 8;

VK_TAB = 9;

VK_CLEAR = 12;

VK_RETURN = 13;

VK_SHIFT = $10;

VK_CONTROL = 17;

VK_MENU = 18;

VK_PAUSE = 19;

VK_CAPITAL = 20;

VK_KANA = 21;

VK_HANGUL = 21;

VK_JUNJA = 23;

VK_FINAL = 24;

VK_HANJA = 25;

VK_KANJI = 25;

VK_CONVERT = 28;

VK_NONCONVERT = 29;

VK_ACCEPT = 30;

VK_MODECHANGE = 31;

VK_ESCAPE = 27;

VK_SPACE = $20;

VK_PRIOR = 33;

VK_NEXT = 34;

VK_END = 35;

VK_HOME = 36;

VK_LEFT = 37;

VK_UP = 38;

VK_RIGHT = 39;

VK_DOWN = 40;

VK_SELECT = 41;

VK_PRINT = 42;

VK_EXECUTE = 43;

VK_SNAPSHOT = 44;

VK_INSERT = 45;

VK_DELETE = 46;

VK_HELP = 47;

{ VK_0 thru VK_9 are the same as ASCII '0' thru '9' ($30 - $39) }

{ VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' ($41 - $5A) }

VK_LWIN = 91;

VK_RWIN = 92;

VK_APPS = 93;

VK_NUMPAD0 = 96;

VK_NUMPAD1 = 97;

VK_NUMPAD2 = 98;

VK_NUMPAD3 = 99;

VK_NUMPAD4 = 100;

VK_NUMPAD5 = 101;

VK_NUMPAD6 = 102;

VK_NUMPAD7 = 103;

VK_NUMPAD8 = 104;

VK_NUMPAD9 = 105;

VK_MULTIPLY = 106;

VK_ADD = 107;

VK_SEPARATOR = 108;

VK_SUBTRACT = 109;

VK_DECIMAL = 110;

VK_DIVIDE = 111;

VK_F1 = 112;

VK_F2 = 113;

VK_F3 = 114;

VK_F4 = 115;

VK_F5 = 116;

VK_F6 = 117;

VK_F7 = 118;

VK_F8 = 119;

VK_F9 = 120;

VK_F10 = 121;

VK_F11 = 122;

VK_F12 = 123;

VK_F13 = 124;

VK_F14 = 125;

VK_F15 = 126;

VK_F16 = 127;

VK_F17 = 128;

VK_F18 = 129;

VK_F19 = 130;

VK_F20 = 131;

VK_F21 = 132;

VK_F22 = 133;

VK_F23 = 134;

VK_F24 = 135;

VK_NUMLOCK = 144;

VK_SCROLL = 145;

{ VK_L & VK_R - left and right Alt, Ctrl and Shift virtual keys.

Used only as parameters to GetAsyncKeyState() and GetKeyState().

No other API or message will distinguish left and right keys in this way. }

VK_LSHIFT = 160;

VK_RSHIFT = 161;

VK_LCONTROL = 162;

VK_RCONTROL = 163;

VK_LMENU = 164;

VK_RMENU = 165;

VK_PROCESSKEY = 229;

VK_ATTN = 246;

VK_CRSEL = 247;

VK_EXSEL = 248;

VK_EREOF = 249;

VK_PLAY = 250;

VK_ZOOM = 251;

VK_NONAME = 252;

VK_PA1 = 253;

VK_OEM_CLEAR = 254;

 

*************************************

 

Delphi - .....................................

 

Key Kodları

Key Kodlari

 

{ Virtual Keys, Standard Set }

VK_LBUTTON = 1;

VK_RBUTTON = 2;

VK_CANCEL = 3;

VK_MBUTTON = 4; { NOT contiguous with L & RBUTTON }

VK_BACK = 8;

VK_TAB = 9;

VK_CLEAR = 12;

VK_RETURN = 13;

VK_SHIFT = $10;

VK_CONTROL = 17;

VK_MENU = 18;

VK_PAUSE = 19;

VK_CAPITAL = 20;

VK_KANA = 21;

VK_HANGUL = 21;

VK_JUNJA = 23;

VK_FINAL = 24;

VK_HANJA = 25;

VK_KANJI = 25;

VK_CONVERT = 28;

VK_NONCONVERT = 29;

VK_ACCEPT = 30;

VK_MODECHANGE = 31;

VK_ESCAPE = 27;

VK_SPACE = $20;

VK_PRIOR = 33;

VK_NEXT = 34;

VK_END = 35;

VK_HOME = 36;

VK_LEFT = 37;

VK_UP = 38;

VK_RIGHT = 39;

VK_DOWN = 40;

VK_SELECT = 41;

VK_PRINT = 42;

VK_EXECUTE = 43;

VK_SNAPSHOT = 44;

VK_INSERT = 45;

VK_DELETE = 46;

VK_HELP = 47;

{ VK_0 thru VK_9 are the same as ASCII '0' thru '9' ($30 - $39) }

{ VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' ($41 - $5A) }

VK_LWIN = 91;

VK_RWIN = 92;

VK_APPS = 93;

VK_NUMPAD0 = 96;

VK_NUMPAD1 = 97;

VK_NUMPAD2 = 98;

VK_NUMPAD3 = 99;

VK_NUMPAD4 = 100;

VK_NUMPAD5 = 101;

VK_NUMPAD6 = 102;

VK_NUMPAD7 = 103;

VK_NUMPAD8 = 104;

VK_NUMPAD9 = 105;

VK_MULTIPLY = 106;

VK_ADD = 107;

VK_SEPARATOR = 108;

VK_SUBTRACT = 109;

VK_DECIMAL = 110;

VK_DIVIDE = 111;

VK_F1 = 112;

VK_F2 = 113;

VK_F3 = 114;

VK_F4 = 115;

VK_F5 = 116;

VK_F6 = 117;

VK_F7 = 118;

VK_F8 = 119;

VK_F9 = 120;

VK_F10 = 121;

VK_F11 = 122;

VK_F12 = 123;

VK_F13 = 124;

VK_F14 = 125;

VK_F15 = 126;

VK_F16 = 127;

VK_F17 = 128;

VK_F18 = 129;

VK_F19 = 130;

VK_F20 = 131;

VK_F21 = 132;

VK_F22 = 133;

VK_F23 = 134;

VK_F24 = 135;

VK_NUMLOCK = 144;

VK_SCROLL = 145;

{ VK_L & VK_R - left and right Alt, Ctrl and Shift virtual keys.

Used only as parameters to GetAsyncKeyState() and GetKeyState().

No other API or message will distinguish left and right keys in this way. }

VK_LSHIFT = 160;

VK_RSHIFT = 161;

VK_LCONTROL = 162;

VK_RCONTROL = 163;

VK_LMENU = 164;

VK_RMENU = 165;

VK_PROCESSKEY = 229;

VK_ATTN = 246;

VK_CRSEL = 247;

VK_EXSEL = 248;

VK_EREOF = 249;

VK_PLAY = 250;

VK_ZOOM = 251;

VK_NONAME = 252;

VK_PA1 = 253;

VK_OEM_CLEAR = 254;

 

*************************************

 

Delphi - .....................................

 

Bilinmeyen bir sql ile ne zaman Query1.Open, ne zaman Query1.ExecSql ?

Bilinmeyen bir sql ile ne zaman Query1.Open, ne zaman Query1.ExecSql ?

 

{

Kullanicinin Gerek select, gerekse Update, Insert vb

komutlarini hatasiz calistirmak icin kullaniniz.

}

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  Query1.Close;

  Query1.Sql.Text :=Memo1.Lines.Text;

  try

   Query1.Open;

  except

   on E: Exception do

    if not (E is ENoResultSet) then // eger bunun disinda hata varsa

     raise;

  end;

end;

 

 

***********************

 

Delphi - .....................................

 

Bilinmeyen bir sql ile ne zaman Query1.Open, ne zaman Query1.ExecSql ?

Bilinmeyen bir sql ile ne zaman Query1.Open, ne zaman Query1.ExecSql ?

 

{

Kullanicinin Gerek select, gerekse Update, Insert vb

komutlarini hatasiz calistirmak icin kullaniniz.

}

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  Query1.Close;

  Query1.Sql.Text :=Memo1.Lines.Text;

  try

   Query1.Open;

  except

   on E: Exception do

    if not (E is ENoResultSet) then // eger bunun disinda hata varsa

     raise;

  end;

end;

 

 

***********************

 

Delphi - .....................................

 

DBGrid verilerini (TQUERY) Excel sayfasina aktarma

DBGrid verilerini (TQUERY) Excel sayfasina aktarma

 

 

{Bu kod ornegi herhangi bir table'dan

Ad ve Soyad verilerini ceken TQuery verilerini,

Excelde yeni bir calisma sayfasi

acip icine yazar.}

 

 

{uses satirina comobj unitini ekleyin}

 

procedure TForm1.Button1Click(Sender: TObject);

var

  v,sayfa:variant;{v excel prg, sayfa calisma sayfasi}

  say,i:integer;

begin

  query1.open;

  say:=query1.recordcount;//query kayit sayisi

  v:=createoleobject('excel.application');//exceli yarat

  v.workbooks.add;//yeni calisma kitabini ekle

  sayfa:=v.workbooks[1].worksheets[1];{Birinci calisma sayfasini sayfa degiskenine ata}

  query1.first;

  for i:=1 to say do

    begin

    sayfa.cells[i,1]:=query1ad.text;

    sayfa.cells[i,2]:=query1soyad.text;

    query1.next;

    end;

v.visible:=true;//Exceli acip verileri goster

end;

 

 

***************************************

 

Delphi - .....................................

 

DBGrid verilerini (TQUERY) Excel sayfasina aktarma

DBGrid verilerini (TQUERY) Excel sayfasina aktarma

 

 

{Bu kod ornegi herhangi bir table'dan

Ad ve Soyad verilerini ceken TQuery verilerini,

Excelde yeni bir calisma sayfasi

acip icine yazar.}

 

 

{uses satirina comobj unitini ekleyin}

 

procedure TForm1.Button1Click(Sender: TObject);

var

  v,sayfa:variant;{v excel prg, sayfa calisma sayfasi}

  say,i:integer;

begin

  query1.open;

  say:=query1.recordcount;//query kayit sayisi

  v:=createoleobject('excel.application');//exceli yarat

  v.workbooks.add;//yeni calisma kitabini ekle

  sayfa:=v.workbooks[1].worksheets[1];{Birinci calisma sayfasini sayfa degiskenine ata}

  query1.first;

  for i:=1 to say do

    begin

    sayfa.cells[i,1]:=query1ad.text;

    sayfa.cells[i,2]:=query1soyad.text;

    query1.next;

    end;

v.visible:=true;//Exceli acip verileri goster

end;

 

 

***************************************

 

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol