Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

DelphiÖи߼¶DLLµÄ±àдºÍµ÷Óü¼ÇÉ

¸ù¾ÝDelphiÌṩµÄÓÐ¹Ø DLL±àдºÍµ÷ÓõİïÖúÐÅÏ¢£¬Äã¿ÉÒԺܿìÍê³ÉÒ»°ãµÄ DLL±àдºÍµ÷ÓÃµÄ Ó¦ÓóÌÐò¡£±¾ÎĽéÉܵÄÖ÷ÌâÊÇÈçºÎ±àдºÍµ÷ÓÃÄܹ»´«µÝ¸÷ÖÖ²ÎÊý£¨°üÀ¨¶ÔÏóʵÀý£©µÄ DLL¡£ÀýÈ磬 Ö÷½Ð³ÌÐò´«µÝ¸ø DLLÒ»¸öADOConnection ¶ÔÏóʾÀý×÷Ϊ²ÎÊý£¬ DLLÖеĺ¯ÊýºÍ¹ý³Ìµ÷ÓÃͨ¹ý¸Ã¶ÔÏó ʵÀý·ÃÎÊÊý¾Ý¿â¡£
ÐèÒªÃ÷ȷһЩ»ù±¾¸ÅÄî¡£¶ÔÓÚ DLL£¬ÐèÒªÔÚÖ÷³ÌÐòÖаüº¬ exports×Ӿ䣬ÓÃÓÚÏòÍâ½çÌṩµ÷Óà ½Ó¿Ú£¬×Ó¾äÖоÍÊÇһϵÁк¯Êý»ò¹ý³ÌµÄÃû×Ö¡£¶ÔÓÚÖ÷½Ð·½£¨µ÷Óà DLLµÄÓ¦ÓóÌÐò»òÆäËüµÄ DLL£©£¬ ÔòÐèÒªÔÚµ÷ÓÃ֮ǰ½øÐÐÍⲿÉùÃ÷£¬¼´external±£Áô×ÖָʾµÄÉùÃ÷¡£ÕâЩÊDZàд DLLºÍµ÷Óà DLL±ØÐë ¾ß±¸µÄÒªËØ¡£
ÁíÍâÐèÒªÁ˽âObject Pascal ÖÐÓйص÷ÓÃЭÒéµÄÄÚÈÝ¡£ÔÚObject Pascal ÖУ¬¶ÔÓÚ¹ý³ÌºÍº¯Êý ÓÐÒÔÏÂÎåÖÖµ÷ÓÃЭÒ飺
ָʾ×Ö ²ÎÊý´«µÝ˳Ðò ²ÎÊýÇå³ýÕß ²ÎÊýÊÇ·ñʹÓüĴæÆ÷
register ×Ô×óÏòÓÒ ±»µ÷Àý³Ì ÊÇ
pascal ×Ô×óÏòÓÒ ±»µ÷Àý³Ì ·ñ
cdecl ×ÔÓÒÏò×ó µ÷ÓÃÕß ·ñ
stdcall ×ÔÓÒÏò×ó ±»µ÷Àý³Ì ·ñ
safecall ×ÔÓÒÏò×ó ±»µ÷Àý³Ì ·ñ
ÕâÀïµÄָʾ×Ö¾ÍÊÇÔÚÉùÃ÷º¯Êý»ò¹ý³Ìʱ¸½¼ÓÔÚÀý³Ì±êÌâÖ®ºóµÄ±£Áô×Ö£¬Ä¬ÈÏΪregister£¬¼´ÊÇ Î¨Ò»Ê¹Óà CPU¼Ä´æÆ÷µÄ²ÎÊý´«µÝ·½Ê½£¬Ò²ÊÇ´«µÝËÙ¶È×î¿ìµÄ·½Ê½£»
pascal: µ÷ÓÃЭÒé½öÓÃÓÚÏòºó¼æÈÝ£¬¼´Ïò¾ÉµÄ°æ±¾¼æÈÝ£»
cdecl: ¶àÓÃÓÚ CºÍ C++ÓïÑÔ±àдµÄÀý³Ì£¬Ò²ÓÃÓÚÐèÒªÓɵ÷ÓÃÕßÇå³ý²ÎÊýµÄÀý³Ì£»
stdcall: ºÍsafecallÖ÷ÒªÓÃÓÚµ÷ÓÃWindows API º¯Êý£»ÆäÖÐsafecall»¹ÓÃÓÚË«Öؽӿڡ£
ÔÚ±¾ÀýÖУ¬½«Ê¹Óõ÷ÓÃЭÒécdecl £¬ÒòΪ±»µ÷ÓÃµÄ DLLÖУ¬Ê¹ÓõÄÊý¾Ý¿âÁ¬½ÓÊÇÓÉÖ÷½Ð·½´«µÝ µÃµ½µÄ£¬²¢ÇÒÐèÒªÓÉÖ÷½Ð·½´¦ÀíÁ¬½ÓµÄ¹Ø±ÕºÍÏú»Ù¡£
ÏÂÃæÊÇ DLLÍêÕûÔ´³ÌÐòºÍÖ÷½Ð³ÌÐòÍêÕûÔ´³ÌÐò¡£°üÀ¨ÒÔÏÂËĸöÎļþ£º
Project1.DPR {Ö÷½Ð³ÌÐò}
Unit1.PAS {Ö÷½Ð³ÌÐòµ¥Ôª}
Project2.DPR {DLL}
Unit2.PAS {DLLµ¥Ôª}
{---------- DLL Ö÷³ÌÐò Project2.DPR ----------}
library Project2;
uses
SysUtils,
Classes,
Unit2 in 'Unit2.pas' {Form1};
{$R *.RES}
{ ÏÂÃæµÄÓï¾äÓÃÓÚÏòµ÷Óøà DLLµÄ³ÌÐòÌṩµ÷ÓÃ½Ó¿Ú }
exports
DoTest; { ¹ý³ÌÀ´×Ôµ¥ÔªUnit2 }
begin
end.
{---------- DLLÖеĵ¥Ôª Unit2.PAS ----------}
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ADODB, StdCtrls, Menus;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;{ ±¾µØÊý¾Ý¿âÁ¬½Ó }
Memo1: TMem


Ïà¹ØÎĵµ£º

Smarter Records in Turbo Delphi / Delphi 2006

type
TTurboRecord = record
strict private
fNameValue : integer;
function GetName: string;
public
NamePrefix : string;
constructor Create(const initNameValue : integer) ;
property Name : string read GetName;
end;
var
Form1: TForm1;
implementation
{$R *.dfm} ......

Delphi Êý×é Ïê½â

¼¼Êõ½»Á÷,DH½²½â. Ê×ÏÈÎÒÃÇÒªÖªµÀʲôÊÇÊý×é?Êý×éÊÇÒ»¶ÑÏàͬÌØÐÔÊý¾ÝµÄÒ»¸ö¼¯ºÏ,Ò²¾ÍÊÇÿ¸öÔªËصÄÀàÐͱØÐëÊÇÒ»ÑùµÄ,µ±È»ÔÚÆäËûһЩÈõÓï·¨µÄÓïÑÔÀïÃæ,Êý×éµÄÔªËØ¿ÉÒÔǧÆæ°Ù¹Ö.
Àý×Ó: Var
A: Array[ 0..2 ] Of Integer ;
Begin
A[ 0 ] := 1 ;
A[ 1 ] := 1.0 ; //ÕâÀïÊÇ´íµÄ,ÒòΪÿ¸öÔªËض¼±ØÐëÊÇIntegerÀàÐ ......

Delphi abc

1. ×Ö·û´®Á¬½ÓÖ±½ÓÓÃ+£¬ÓëJavaºÍPythonÖеÄÏàͬ
2. Ö´ÐÐÍⲿÃüÁîʹÓÃwinexec£¬ShellExecute
    eg. ShellExecute(0, 'open', 'jre/bin/java', '-lang zh-CN', 'E:\myfolder', SW_SHOW);
3. ÅжÏÎļþ¡¢Îļþ¼ÐÊÇ·ñ´æÔÚ
    FileExists('C:\Users\bill\somefile.txt')
    ......

Override Delphi Form's Restore Operation

{ Private declarations }
procedure WMSysCommand (var Msg: TWMSysCommand) ; message WM_SYSCOMMAND;
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_RESTORE then
begin
ShowMessage('SC_RESTORE');
if self.WindowState = wsMaximized then
begin
......

ÔÚdelphi 7ÖÐʵÏÖ»ñÈ¡ºº×ÖÆ´ÒôÊ××Öĸ

     ¹«Ë¾µÄ²ÍÒûϵͳ³öÆ·µÄÖú¼ÇÂ룬»¹Ã»ÊµÏÖ×Ô¶¯´Ó³öÆ·Ãû³Æ»ñÈ¡ºº×ÖÆ´ÒôÊ××Öĸ¡£
   ËùÒÔÔÚÍøÉÏÕÒÁËÈýÖÖ½â¾ö·½·¨£¬
    Ò»ÖÖÊÇkaguo µÄʹÓó£Óúº×ÖÆ´Òô²éÕÒ·½·¨£¬ÕâÖÖ´úÂëÊ®·Ö¼òµ¥£¬ÊµÏÖ·½±ã£¬µ«ÊÇÕâÖÖ´úÂë½ö½öÊÇÒ»¼¶×ֿ⣬ֻ֧³ÖÈýǧÁ㼸¸ö×ֵġ£
//»ñÈ¡ÖÐÎÄ×Ö´®µÄÉùĸµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ