¡¶Delphi Ëã·¨ÓëÊý¾Ý½á¹¹¡·: Êý¾Ý¶ÔÆë
ΪÁ˼ӿìÓ²¼þµÄ·ÃÎÊËÙ¶È, ±àÒëÆ÷ͨ³£ÒªÊ¹ÓÃ"Êý¾Ý¶ÔÆë", Æ©Èç:
//ÏÂÃæ½á¹¹ÖÐ: SizeOf(TRec) = 6; ÒòΪ b ÔÚÕâÀïÒ²ÒªÕ¼ 2 ×Ö½Ú.
TRec = record
a: Word;
b: Byte;
c: Word;
end
;
//ÏÂÃæ½á¹¹ÖÐ: SizeOf(TRec) = 16; ÕâÀïµÄ a ºÍ b ¹²Õ¼ÁË 8 ¸ö×Ö½Ú.
TRec = record
a: Byte;
b: Byte;
c: Double;
end
;
//ÏÂÃæ½á¹¹ÖÐ: SizeOf(TRec) = 8; ÕâÀïµÄ a ºÍ b ¹²Õ¼ÁË 4 ¸ö×Ö½Ú.
TRec = record
a: Byte;
b: Byte;
c: Integer;
end
;
//ÏÂÀýʹÓÃÁ˽ṹѹËõ(ѹËõºó¾Í¶Ô²»ÆëÁË), ËüÃǵĴóС»á·Ö±ðÊÇ: 2¡¢1¡¢8 ×Ö½Ú
TRec = packed
record
a: Word;
b: Byte;
c: Double;
end
;
ÏÂÃæÊÇÒ»¸ö²âÊÔ:
unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class
(TForm)
Memo1: TMemo;
procedure
FormCreate(Sender: TObject);
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
rec1 = record
x: Integer;
y: Integer;
z: Integer;
end
;
rec2 = record
x: Integer;
y: Byte;
z: Integer;
end
;
rec3 = packed
record
x: Integer;
y: Byte;
z: Integer;
end
;
procedure
TForm1.FormCreate(Sender: TObject);
const
DashLine = '----------------------------------'
;
var
r1: rec1;
r2: rec2;
r3: rec3;
begin
Memo1.Align := alClient;
Memo1.Clear;
Memo1.Lines.Add(Format('rec1 ½á¹¹µÄ´óСÊÇ: %d'
, [SizeOf(rec1)]));
Memo1.Lines.Add(Format('rec2 ½á¹¹µÄ´óСÊÇ: %d'
, [SizeOf(rec2)]));
Memo1.Lines.Add(Format('rec3 ½á¹¹µÄ´óСÊÇ: %d'
, [SizeOf(rec3)]));
Memo1.Lines.Add(DashLine);
Memo1.Lines.Add(Format('r1 ÖÐ x µÄµØÖ·ÊÇ: %d'
, [Integer(@r1.x)]));
Memo1.Lines.Add(Format('r1 ÖÐ y µÄµØÖ·ÊÇ: %d'
, [Integer(@r1.y)]));
Memo1.Lines.Add(Format('r1 ÖÐ z µÄµØÖ·ÊÇ: %d'
, [Integer(@r1.z)]));
Memo1.Lines.Add(DashLine);
Memo1.Lines.Add(Format('r2 ÖÐ x µÄµØÖ·ÊÇ: %d'
, [Integer(@r2.x)]));
Memo1.Lines.Add(Format('r2 ÖÐ y µÄµØÖ·ÊÇ: %d'
, [Integer(@r2.y)]));
Memo1.Lines.Add(Format('
Ïà¹ØÎĵµ£º
1£®µ÷ÓÃAPIº¯Êý
procedure CopyFile(fromFileName,ToFileName:string);
var
f1,f2:file;
Begin
AssignFile(f1,fromFileName); file://Ö¸¶¨Ô´ÎļþÃû
AssignFile(f2,ToFileName); file://Ö¸¶¨Ä¿±êÎļþÃû
Reset(f1);
Try
Rewrite(f2);
Try
If Lzcopy(TfileRec(f1).handle,TfileRec(f2).Handle)<0
Then
Raise ......
ÅóÓÑ£¬ÏÈÒªµ¼Èë XDICTGRB_TLB £¬È»ºóÓÃÏÂÃæµÄsource£¬×¢ÒâTForm1 = class(TForm,IXDictGrabSink) //!!!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, XDICTGRB_TLB;
type
TForm1 = class(TForm,IXDictGrabSink) //!!!
GrabPro ......
(Ò») ʹÓö¯Ì¬´´½¨µÄ·½·¨
Ê×ÏÈ´´½¨ Excel ¶ÔÏó£¬Ê¹ÓÃComObj:
var ExcelApp: Variant;
ExcelApp := CreateOleObject( 'Excel.Application' );
1) ÏÔʾµ±Ç°´°¿Ú£º
ExcelApp.Visible := True;
2) ¸ü¸Ä Excel ±êÌâÀ¸£º
ExcelApp.Caption := 'Ó¦ÓóÌÐòµ÷Óà Microsoft Excel';
3) Ìí¼Óй¤×÷²¾£º
ExcelApp.WorkBooks.Add ......
¶Á“Delphi2010,DELPHIµÄÏ£Íû?”ÓиÐ
ÔÎÄ£ºhttp://www.gowjq.com/forum-29-1.html
1£© Ê¢´óµÄÖ÷Òª¿ª·¢¹¤¾ßÊÇDelphi, Ïê¼û£º http://act.sdo.com/Delphi/£¬ ÓÎÏ·ÊÇÒ»ÖÖ¸´ÔÓ½»»¥½çÃæµÄ¿ª·¢£¬Delphi¿ÉÒÔʤÈΡ£Í¬Ñù×÷ΪÆóÒµÓ¦ÓõÄÇ°¶Ë£¬ÓÃDELPHI¿ª·¢Ò²ÊǺܺõÄÑ¡Ôñ¡£
2£© Ò ......