DeWeb --- Hello,World!


1.新建一個DLL,命名為hello.dpr

2.新增一個Form.(File->New->VCL Form - Delphi),建議不要更改單元名稱和Form名稱,即分別為unit1.pas和Form1

3.在Form1中添加一個Label,設置其Caption為"Hello,DeWeb"

4.將hello.dpr源文件代碼更改為
//====================================
library hello;

uses
ShareMem, SysUtils, Forms, Messages, StdCtrls,
Variants, Windows, Classes,
unit1 in 'unit1.pas' {Form1};

{$R *.res}
type
PdwGetEvent=function (ACtrl:TComponent;AData:String):string; StdCall;
var
DLLApp : TApplication;
DLLScreen : TScreen;
function dwLoad(AParams:String;AApp:TApplication;AScreen:TScreen):TForm;stdcall;
var
AForm : TForm1;
begin
//
Application := AApp;
Screen := AScreen;
//
AForm := TForm1.Create(nil);
AForm.Hint := AParams;
Result := AForm;
end;

procedure DLLUnloadProc(dwReason: DWORD);
begin
if dwReason = DLL_PROCESS_DETACH then begin
Application := DLLApp; //恢復
Screen := DLLScreen;
end;
end;

exports
dwLoad;

begin
DLLApp := Application; //保存 DLL 中初始的 Application
DLLScreen := Screen;
DLLProc := @DLLUnloadProc;//保證卸載時恢復原Application
DLLUnloadProc(DLL_PROCESS_DETACH);
end.
//====================================

5.編譯生成hello.dll,復制到source\runtime\apps中

6.運行source\runtime\DeWebServer.exe,注意使端口為80

7.打開現代瀏覽器(Chrome/FireFox等),打開http://127.0.0.1/hello.dw


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM