ËäÊÇÔ´´£¬µ«ÊÇÊDzο¼¹ý±ðÈ˵Ä×÷Æ·£¬È»ºó×Ô¼ºÖØÐÂдµÄ£¬Ä¿µÄÊÇÒª¸ø³õѧÕßÒ»¸ö¸üÈÝÒ×Ã÷°×¡£
ÓÃDELPHI´´½¨DLLÎļþ£¬·â×°´°ÌåµÄʵÏÖ·½·¨ÊµÀý£º
¼´Ò»¸ö³ÌÐò²»ÔÙÊǵ¥Ò»µÄÒ»¸öEXEÎļþÁË£¬¶øÊÇÓÉÒ»¸öEXEÎļþ¼ÓN¸öDLLÎļþ×é³É£¬ÕâÑù×öµÄÔÒòÊÇ·½±ãÒÔºóµÄά»¤Óë¸üУ¬Ò²ÊÇ¿çƽ̨¿ª·¢µÄÖØÒªÒ»²½¡£
1£¬ ´ò¿ªDELPHI£¬Ð½¨Ò»¸öDll Wizard
2£¬ ÔÚн¨µÄDllÀïн¨Ò»¸öForm
3£¬ ÔÚн¨µÄFormÀïuses stdctrls
4£¬ ÔÚvarÏÂÃæд£º
Procedure synapp(App:THandle);stdcall;
Procedure showform;stdcall;
5£¬ È»ºóÔÚimplementation ÏÂÃæuses math
6£¬ ÔÚ{$R *.dfm}ÏÂÃæд
Procedure synapp(App:THandle);stdcall;
Begin
Application.Handle:=app;
End;
Procedure showform;stdcall;
Begin
Form1:=Tform1.create(application);
Form1.show;
End;
7£¬ ÔÚdllµÄLibraryÎļþÀïµÄ{$R *.res}ÏÂÃæд£º
exports
Sysapp,show;
ÉÏÃæµ½´ËΪֹÍê³ÉÁËDLL·â×°´°ÌåµÄ´´½¨
ÏÂÃæÊǵ÷ÓÃÁË
1£¬ ÔÚÒªµ÷ÓÃDLLÎļþµÄ³ÌÐòµÄvarÏÂд£º
Procedure synapp(App:THandle);stdcall;external ‘my.dll’ ;//----ÄãµÄDLLÎļþÃû
......
ÓÃDelphi¿ª·¢Êý¾Ý¿âÓ¦Óã¬Ò»°ã»áÉæ¼°µ½ÉÁÆÁ£¨Splash£©¡¢µÇ¼´°¿Ú¡¢Ö÷Êý¾ÝÄ£¿é£¨»òÖ÷Êý¾Ý¿âÁ¬½Ó£©ÒÔ¼°Ö÷´°¿Ú¡£Í¨³£ÔÚÏîÄ¿ÎļþÖУ¬splash´°¿ÚÏÔʾ¹ý£¬Ò»Ð©ÐèÒª¼ÓÔصÄ×ÊÔ´¡¢´°¿Ú¼ÓÔعýºó£¬Application.Run֮ǰ£¬½øÐÐÓû§µÇ¼¡£
//²âÊÔCSDN²©¿Í¶ÔDELPHI´úÂëµÄÖ§³Ö
program TEST;
uses
Forms,
Windows,
MainF in 'MainF.pas' {frmMain},
SplashF in 'SplashF.pas' {frmSplash},
mainDM in 'mainDM.pas' {dmMain: TDataModule},
LoginF in 'LoginF.pas' {frmLogin};
{$R *.RES}
var
frmMain: TfrmMain;
dmMain: TdmMain;
begin
Application.Initialize;
//ÏÔʾ·âÃæ
SplashF.Show;
try
//´´½¨ÐèÒªµÄ×ÊÔ´
Application.CreateForm(TdmMain, dmMain);
Application.CreateForm(TfrmMain, frmMain);
//...
finally
SplashF.Close;
end;
if LoginF.Login() then //ºô½ÐµÇ¼´°¿Ú
Application.Run;
end.
´Ëʱ£¬¿ÉÄÜÓõ½µÄÊý¾ÝÁ¬½ÓÒѾ½¨Á¢ÆðÀ´ÁË£¬µÇ¼¾Í¿ÉÒÔ½øϵͳ¡£
LoginF.pas
unit LoginF;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
......
//¶¨ÒåÈ«¾Ö±äÁ¿
public
{ Public declarations }
outlook,MailItem,Recipient:variant;
OutlookNameSpace:variant;
OutlookFolder:variant;
OutlookAttachment:variant;
//´´½¨´ò¿ªoutlook
procedure TForm1.CreateOutLook;
begin
try
outlook:=CreateOleObject('OutLook.application');
except
Outlook:=GetActiveOleObject('Outlook.Application');
end;
OutlookNameSpace:=Outlook.GetNamespace('MAPI');
OutlookFolder:=OutlookNameSpace.GetDefaultFolder(6);
MailItem:=OutlookFolder.items;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CreateOutLook;
WebBrowser1.Navigate('about:');
end;
//ËÑË÷δ¶ÁÓʼþ ²¢ÓÃwebbrowser1ÏÔʾÓʼþÄÚÈÝ
procedure TForm1.bt_SearchMailClick(Sender: TObject);
var
sch:Variant;
Smail:Variant;
strF:string;
i:integer;
mailbody:WideString;
begin
strF:='[senderEmailAddress]="%s" and [unread]=true';
strF:=Format(strF,[Trim(Edit1.Text)]);
sch:=MailItem.Restrict(strF);
mailbody:='ÕÒµ½· ......
32λDelphi³ÌÐòÖпÉÀûÓÃTRegistry¶ÔÏóÀ´´æȡע²á±íÎļþÖеÄÐÅÏ¢¡£
¡¡¡¡Ò»¡¢´´½¨ºÍÊÍ·ÅTRegistry¶ÔÏó
¡¡¡¡1.´´½¨TRegistry¶ÔÏó¡£ÎªÁ˲Ù×÷×¢²á±í£¬Òª´´½¨Ò»¸öTRegistry¶ÔÏó£ºARegistry := TRegistry.Create£»
¡¡¡¡2.ÊÍ·ÅTRegistry¶ÔÏ󡣶Ô×¢²á±í²Ù×÷½áÊøºó£¬Ó¦ÊÍ·ÅTRegistry¶ÔÏóËùÕ¼Äڴ棺ARegistry.Destroy¡£
¡¡¡¡¶þ¡¢Ö¸¶¨Òª²Ù×÷µÄ¼ü
¡¡¡¡²Ù×÷×¢²á±íʱ£¬Ê×ÏÈÓ¦Ö¸¶¨²Ù×÷µÄÖ÷¼ü£ºÏȸøÊôÐÔRootKey¸³ÖµÒÔÖ¸¶¨¸ù¼ü£¬È»ºóÓ÷½·¨OpenKeyÀ´Ö¸¶¨Òª²Ù×÷µÄÖ÷¼üÃû¡£
¡¡¡¡1.Ö¸¶¨¸ù¼ü(RootKey)¡£
¡¡¡¡¸ù¼üÊÇ×¢²á±íµÄÈë¿Ú£¬Ò²×¢²á±íÐÅÏ¢µÄ·ÖÀ࣬ÆäÖµ¿ÉΪ£º
¡¡¡¡HKEY—CLASSES—ROOT£º´æ´¢Õû¸öϵͳ¶ÔÏóÀàÐÅÏ¢£¬ÈçActiveX¶ÔÏó×¢²á¡¢Îļþ¹ØÁªµÈÐÅÏ¢¡£
¡¡¡¡HKEY—CURRENT—USER£º´æ´¢µ±Ç°Óû§µÄÅäÖÃÐÅÏ¢¡£ÎªÊôÐÔRootKeyµÄĬÈÏÖµ¡£
¡¡¡¡HKEY—LOCAL—MACHINE£º´æ´¢µ±Ç°ÏµÍ³µÄÈíÓ²¼þÅäÖÃÐÅÏ¢¡£Ó¦ÓóÌÐò×Ô¼ºµÄÐÅÏ¢¿ÉÒÔ´æ´¢Ôڸøù¼üÏ¡£
¡¡HKEY—USERS£º´æ´¢ËùÓÐÓû§Í¨ÓõÄÅäÖÃÐÅÏ¢¡£
¡¡¡¡»¹¿ÉÒÔÊÇHKEY—CURRENT—CONFIG¡¢HKEY—DYN—DATA¡£
¡¡¡¡2.Ö¸¶¨Òª²Ù×÷µÄÖ÷¼ü¡£
¡¡¡¡Function OpenKey(const Key: string; C ......
ÓÃVC++6.0±àдÁËÒ»¸ö¼òµ¥µÄdll£¬ÀïÃæ°üº¬Ò»¸ö¼õ·¨º¯Êýsubtract(int a,int b)£¬DllÃüÃûΪff.Dll
´úÂëÈçÏ£º
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
FF_API int nFf=0;
// This is an example of an e ......
ÓÃVC++6.0±àдÁËÒ»¸ö¼òµ¥µÄdll£¬ÀïÃæ°üº¬Ò»¸ö¼õ·¨º¯Êýsubtract(int a,int b)£¬DllÃüÃûΪff.Dll
´úÂëÈçÏ£º
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
FF_API int nFf=0;
// This is an example of an e ......
Ò»¡¢Formatº¯ÊýµÄÓ÷¨
FormatÊÇÒ»¸öºÜ³£Óã¬È´ÓÖËƺõºÜ·³µÄ·½·¨£¬±¾ÈËÊÔͼ¶ÔÕâ¸ö·½·¨µÄ°ïÖú½øÐÐһЩ·Ò룬ÈÃËüÓÐÒ»¸öÍêÕûµÄ¸Åò£¬ÒÔ¹©´ó¼Ò²éѯ֮Óãº
Ê×ÏÈ¿´ËüµÄÉùÃ÷£º
function Format(const Format: string; const Args: array of const): string; overload;
ÊÂʵÉÏFormat·½·¨ÓÐÁ½¸öÖÖÐÎʽ£¬ÁíÍâÒ»ÖÖÊÇÈý¸ö²ÎÊýµÄ£¬Ö÷ÒªÇø±ðÔÚÓÚËüÊÇḬ̈߳²È«µÄ£¬µ«²¢²»¶àÓã¬ËùÒÔÕâÀïÖ»¶ÔµÚÒ»¸ö½éÉÜ£º
function Format(const Format: string; const Args: array of const): string; overload;
Format²ÎÊýÊÇÒ»¸ö¸ñʽ×Ö·û´®£¬ÓÃÓÚ¸ñʽ»¯ArgsÀïÃæµÄÖµµÄ¡£ArgsÓÖÊÇʲôÄØ£¬ËüÊÇÒ»¸ö±äÌåÊý×飬¼´ËüÀïÃæ¿ÉÒÔÓжà¸ö²ÎÊý£¬¶øÇÒÿ¸ö²ÎÊý¿ÉÒÔ²»Í¬¡£
ÈçÒÔÏÂÀý×Ó£º
Format('my name is %6s',['wind']);
·µ»Øºó¾ÍÊÇ
my name is wind
ÏÖÔÚÀ´¿´Format²ÎÊýµÄÏêϸÇé¿ö£º
FormatÀïÃæ¿ÉÒÔдÆÕͨµÄ×Ö·û´®£¬±ÈÈç'my name is' µ«ÓÐЩ¸ñʽָÁî×Ö·û¾ßÓÐÌØÊâÒâÒ壬±ÈÈç"%6s"
¸ñʽָÁî¾ßÓÐÒÔϵÄÐÎʽ£º
"%" [index ":"] ["-"] [width] ["." prec] type
ËüÊÇÒÔ"%"¿ªÊ¼,¶øÒÔtype½áÊø£¬type±íʾһ¸ö¾ßÌåµÄÀàÐÍ¡£ÖмäÊÇÓÃÀ´¸ñʽ»¯typeÀàÐ͵ÄÖ¸Áî×Ö·û£¬ÊÇ¿ÉÑ¡µÄ¡£
ÏÈÀ´¿´¿´type,type¿ÉÒÔÊÇÒÔÏÂ×Ö·û£º
d Ê® ......