Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 5

Project NEWGUID

Project Structure


NEWGUID.DPR

program NewGUID;

uses
  Forms,
  GUIDForm in 'GUIDForm.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

GUIDFORM.PAS

unit GUIDForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    BtnNew: TButton;
    Memo1: TMemo;
    procedure BtnNewClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  ComObj, ActiveX;

procedure TForm1.BtnNewClick(Sender: TObject);
var
  ID: TGUID;
  S: string;
begin
  if CoCreateGuid (Id) = s_OK then
  begin
    s := GUIDToString (Id);
    Memo1.Lines.Add (S);
  end;
end;

end.

GUIDFORM.DFM

object Form1: TForm1
  Left = 207
  Top = 109
  Width = 435
  Height = 244
  Caption = 'New GUID'
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object BtnNew: TButton
    Left = 8
    Top = 16
    Width = 75
    Height = 25
    Caption = '&New'
    TabOrder = 0
    OnClick = BtnNewClick
  end
  object Memo1: TMemo
    Left = 96
    Top = 16
    Width = 321
    Height = 185
    TabOrder = 1
  end
end