library Tools;{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }uses SysUtils, Classes, windows, forms, Wally_Comm, dialogs, w16 in 'w16.pas' {ForMain}, WmdUntil in 'WmdUntil.pas', ForUF in 'ForUF.pas' {ForU}, w18 in 'w18.pas' {ForUFile}, Dialog1 in 'Dialog1.pas' {MatchDialog}, Match in 'Match.pas' {FrmMatch}, MaxAccount in 'MaxAccount.pas' {ComputeTax}, Remind in 'Remind.pas' {FrmRemind}, SendMail in 'SendMail.pas' {ForSend}, Chat in 'Chat.pas' {FrmChat}, RecvMail in 'RecvMail.pas' {FrmRecv}, SetDesktop in 'SetDesktop.pas' {FrmDesktop}, Cert in 'Cert.pas' {FrmCert}, EmailProfile in 'EmailProfile.pas' {FrmMailPro}, MulCS in 'MulCS.pas' {FrmMCS};{$R *.RES}resourcestring S_ErrFormExist='This form has exist!'; S_ErrCreateForm='The form cause error, please contact Wally!';procedure OFile(OHandle: THandle); var ForMain: TForMain; begin try Application.Handle := OHandle; ForMain := TForMain.Create(nil); ForMain.ShowModal; ForMain.Free; except ForMain.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure UFile(OHandle: THandle); var ForUFile: TForUFile; begin try Application.Handle := OHandle; ForUFile := TForUFile.Create(nil); ForUFile.ShowModal; ForUFile.Free; except ForUFile.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure MailForm(OHandle: THandle); var ForSend: TForSend; begin try Application.Handle := OHandle; ForSend := TForSend.Create(nil); ForSend.ShowModal; // ForSend.Show; ForSend.Free; except ForSend.Free; raise Exception.CreateRes(@S_ErrCreateForm); end end; procedure MatchForm(OHandle: THandle); begin try Application.Handle := OHandle; ShowDlg(TFrmMatch); // FrmMatch := TFrmMatch.Create(Application); // FrmMatch.ShowModal; // FrmMatch.Free; except // FrmMatch.Free; end; end;procedure SetDesktop(OHandle: THandle); var FrmDesktop: TFrmDesktop; begin try Application.Handle := OHandle; FrmDesktop := TFrmDesktop.Create(nil); FrmDesktop.ShowModal; FrmDesktop.Free; except FrmDesktop.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure ComputedTax(OHandle: THandle); var ComputeTax: TComputeTax; begin try Application.Handle := OHandle; ComputeTax := TComputeTax.Create(nil); ComputeTax.ShowModal; ComputeTax.Free; except ComputeTax.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure RemindWork(FHandle: THandle); var FrmRemind: TFrmRemind; begin try Application.Handle := FHandle; FrmRemind := TFrmRemind.Create(nil); FrmRemind.ShowModal; FrmRemind.Free; except FrmRemind.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end; procedure Chat(FHandle: THandle); var FrmChat: TFrmChat; begin try Application.Handle := FHandle; FrmChat := TFrmChat.Create(nil); FrmChat.ShowModal; FrmChat.Free; except FrmChat.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure RecvForm(OHandle: THandle); var FrmRecv: TFrmRecv; begin try Application.Handle := OHandle; FrmRecv := TFrmRecv.Create(nil); FrmRecv.ShowModal; // ForSend.Show; FrmRecv.Free; except FrmRecv.Free; raise Exception.CreateRes(@S_ErrCreateForm); end end;procedure MulChatServer(OHandle: THandle); var FrmMCS: TFrmMCS; begin try Application.Handle := OHandle; FrmMCS := TFrmMCS.Create(nil); FrmMCS.ShowModal; FrmMCS.Free; except FrmMCS.Free; raise Exception.CreateRes(@S_ErrCreateForm); end; end;procedure InitService(const pAction: Integer; const pArgs: array of const); stdcall; begin Case pAction of 1: OFile(LongInt(pArgs[0].VAnsiString)); 2: UFile(LongInt(pArgs[0].VAnsiString)); 3: MailForm(LongInt(pArgs[0].VAnsiString)); 4: MatchForm(LongInt(pArgs[0].VAnsiString)); 5: SetDesktop(LongInt(pArgs[0].VAnsiString)); 6: ComputedTax(LongInt(pArgs[0].VAnsiString)); 7: RemindWork(LongInt(pArgs[0].VAnsiString)); 9: RecvForm(LongInt(pArgs[0].VAnsiString)); 10: MulChatServer(LongInt(pArgs[0].VAnsiString)); 11: Chat(LongInt(pArgs[0].VAnsiString)); end; end;Exports InitService; begin end.
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
windows,
forms,
Wally_Comm,
dialogs,
w16 in 'w16.pas' {ForMain},
WmdUntil in 'WmdUntil.pas',
ForUF in 'ForUF.pas' {ForU},
w18 in 'w18.pas' {ForUFile},
Dialog1 in 'Dialog1.pas' {MatchDialog},
Match in 'Match.pas' {FrmMatch},
MaxAccount in 'MaxAccount.pas' {ComputeTax},
Remind in 'Remind.pas' {FrmRemind},
SendMail in 'SendMail.pas' {ForSend},
Chat in 'Chat.pas' {FrmChat},
RecvMail in 'RecvMail.pas' {FrmRecv},
SetDesktop in 'SetDesktop.pas' {FrmDesktop},
Cert in 'Cert.pas' {FrmCert},
EmailProfile in 'EmailProfile.pas' {FrmMailPro},
MulCS in 'MulCS.pas' {FrmMCS};{$R *.RES}resourcestring
S_ErrFormExist='This form has exist!';
S_ErrCreateForm='The form cause error, please contact Wally!';procedure OFile(OHandle: THandle);
var
ForMain: TForMain;
begin
try
Application.Handle := OHandle;
ForMain := TForMain.Create(nil);
ForMain.ShowModal;
ForMain.Free;
except
ForMain.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure UFile(OHandle: THandle);
var
ForUFile: TForUFile;
begin
try
Application.Handle := OHandle;
ForUFile := TForUFile.Create(nil);
ForUFile.ShowModal;
ForUFile.Free;
except
ForUFile.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure MailForm(OHandle: THandle);
var
ForSend: TForSend;
begin
try
Application.Handle := OHandle;
ForSend := TForSend.Create(nil);
ForSend.ShowModal;
// ForSend.Show;
ForSend.Free;
except
ForSend.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end
end;
procedure MatchForm(OHandle: THandle);
begin
try
Application.Handle := OHandle;
ShowDlg(TFrmMatch);
// FrmMatch := TFrmMatch.Create(Application);
// FrmMatch.ShowModal;
// FrmMatch.Free;
except
// FrmMatch.Free;
end;
end;procedure SetDesktop(OHandle: THandle);
var
FrmDesktop: TFrmDesktop;
begin
try
Application.Handle := OHandle;
FrmDesktop := TFrmDesktop.Create(nil);
FrmDesktop.ShowModal;
FrmDesktop.Free;
except
FrmDesktop.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure ComputedTax(OHandle: THandle);
var
ComputeTax: TComputeTax;
begin
try
Application.Handle := OHandle;
ComputeTax := TComputeTax.Create(nil);
ComputeTax.ShowModal;
ComputeTax.Free;
except
ComputeTax.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure RemindWork(FHandle: THandle);
var
FrmRemind: TFrmRemind;
begin
try
Application.Handle := FHandle;
FrmRemind := TFrmRemind.Create(nil);
FrmRemind.ShowModal;
FrmRemind.Free;
except
FrmRemind.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;
procedure Chat(FHandle: THandle);
var
FrmChat: TFrmChat;
begin
try
Application.Handle := FHandle;
FrmChat := TFrmChat.Create(nil);
FrmChat.ShowModal;
FrmChat.Free;
except
FrmChat.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure RecvForm(OHandle: THandle);
var
FrmRecv: TFrmRecv;
begin
try
Application.Handle := OHandle;
FrmRecv := TFrmRecv.Create(nil);
FrmRecv.ShowModal;
// ForSend.Show;
FrmRecv.Free;
except
FrmRecv.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end
end;procedure MulChatServer(OHandle: THandle);
var
FrmMCS: TFrmMCS;
begin
try
Application.Handle := OHandle;
FrmMCS := TFrmMCS.Create(nil);
FrmMCS.ShowModal;
FrmMCS.Free;
except
FrmMCS.Free;
raise Exception.CreateRes(@S_ErrCreateForm);
end;
end;procedure InitService(const pAction: Integer; const pArgs: array of const); stdcall;
begin
Case pAction of
1: OFile(LongInt(pArgs[0].VAnsiString));
2: UFile(LongInt(pArgs[0].VAnsiString));
3: MailForm(LongInt(pArgs[0].VAnsiString));
4: MatchForm(LongInt(pArgs[0].VAnsiString));
5: SetDesktop(LongInt(pArgs[0].VAnsiString));
6: ComputedTax(LongInt(pArgs[0].VAnsiString));
7: RemindWork(LongInt(pArgs[0].VAnsiString));
9: RecvForm(LongInt(pArgs[0].VAnsiString));
10: MulChatServer(LongInt(pArgs[0].VAnsiString));
11: Chat(LongInt(pArgs[0].VAnsiString));
end;
end;Exports
InitService;
begin
end.