DelphiFan Magazine

Top Menu

Main Menu

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS

logo

DelphiFan Magazine

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS
  • How to add a server application written in UNIGUI to startup?

  • UniGUI Expiry Link Anonymizer

  • UniGUI Add CAPTCHA to the WEB project

  • UniGui. Unique hybrid of Delphi and JS

  • How to transform a blob field into string lines (varchar) in SQL Firebird?

CODE SAMPLESDELPHI
Home›CODE SAMPLES›How create a new uniGUI application

How create a new uniGUI application

By admin
November 8, 2020
1603
0
Share:

First Open your Delphi.You can easily create a new uniGUI application through the uniGUI application wizard in the Delphi IDE (you must use this method to create a new uniGUI application), and follow the wizard interface prompts.

(1) Use uniGUI application wizard to create a new uniGUI application, the main steps are

  1. File->New->Other

2. Select uniGUI for Delphi-> Application Wizard, click “OK”

3. Fill in the project name and project storage directory, and select a project type as required (I usually choose the first one when developing and learning), click “OK”, the system will automatically generate related project codes and several modules and forms.

At this point, the architecture of an application project is automatically generated by the UniGUI wizard. From the above figure, we can see that several modules and forms are automatically generated.Each uniGUI application is composed of a dedicated form of a main form (MainForm) and two dedicated modules (MainModule) and a service module (ServerModule) and is automatically created. The login form (LoginForm) can be selected or added depending on the situation (similar to additional addition, which will be discussed later, there is no here).

1. Standalone Server

The simplest type of project is a standalone server. In this mode, the application server runs directly like a desktop application. It is also a mode for debugging applications. After running the application executable file (it is an EXE file), it will be minimized to the tray icon and run until the user manually terminates it. See below:

An independent application can be accessed from a browser. Just type: http://localhost:8077 in the address bar, where 8077 is the default dedicated port number (listening port) that the application is bound to. Developers can easily modify it in the server module (ServerModule). Standalone mode is only recommended for debugging purposes.

Because it runs as a desktop application, it will be terminated when the current user logs out. Moreover, it will not start automatically after restarting. The mode is most suitable for debugging during development. When your application is running in debug mode, you can set breakpoints, pause, go to the cursor position, and use all the other advanced debugging features of Delphi IDE to debug your application, just like any other VCL application same. It is not recommended to use this mode in a formal use environment because it will not automatically run when the OS restarts. In addition, it can be easily terminated by unauthorized user intervention.

The standalone server project is the simplest type of uniGUI project. It creates an application (EXE file) that runs similar to a desktop application, that is, the application is started and terminated by the user. This type of application is best for debugging purposes. The following is a sample DPR file for a typical newly created standalone server project.

program Project1;
 
uses
  Forms,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main in 'Main.pas' {MainForm: TUniForm};
 
{$R *.res}
 
begin
  Application.Initialize;
  TUniServerModule.Create(Application);
  Application.Run;
end.

2. ISAPI Module

This technology was originally applied to Microsoft IIS products by Microsoft using Windows-based DLL technology. Of course, there are other web servers, such as Apache, which also support loading ISAPI mode. ISAPI mode differs from the previously discussed options in many ways. Most importantly, it does not include a built-in Web server, rather than stand-alone services and Windows services. In ISAPI mode, the IIS server is an HTTP server, and the ISAPI module executes its requests. You can use the uniGUI wizard in Delphi IDE to easily create ISAPI mode applications. After compilation, the uniGUI application will output DLL files instead of EXE files. This DLL file must be deployed to the IIS server (detailed in the ISAPI mode of the Web deployment section). The DLL file generated by uniGUI application supports all IIS versions starting from IIS 5.1. ISAPI mode provides developers with the freedom to deploy many modules on the same server without the need to choose different ports for each application. It also inherits the advantages of all advanced security features in Microsoft IIS.

Running an ISAPI application is as simple as opening the following URL in a browser, and the access format is as follows:

http://localhost/appdir/app.dll
If you have multiple applications in the same folder, you can call them by specifying a different DLL name:
http://localhost/appdir/app.dll
http://localhost/appdir/app2.dll
http://localhost/appdir/appaccount.dll

If you plan to start an ISAPI mode project and choose it as the default deployment method, you can choose this type of project. This project will generate a DLL when compiled. ISAPI modules can be deployed to Microsoft® IIS server or Apache server for Windows. Below is a sample DPR file of a typical newly created ISAPI module project.

library Project1;
 
uses
  uniGUIISAPI,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule};
 
{$R *.res}
 
exports
  GetExtensionVersion,
  HttpExtensionProc,
  TerminateExtension;
end.

3. Standalone Server/ISAPI module

This type of project uses conditional compilation instructions to create a combined project of one of the above two types: standalone server or ISAPI module. If the goal of ISAPI module deployment is formal use, then this type of project is a very good start. Just comment out the first line of the DPR file to convert the stand-alone server to ISAPI DLL.

{$define UNIGUI_VCL} // Comment out this line (that is to say: {.$define UNIGUI_VCL}), you can use this item to change to an ISAPI mode
 
{$ifndef UNIGUI_VCL}
library
{$else}
program
{$endif}
  Project1;
 
uses
  uniGUIISAPI,
  Forms,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main in 'Main.pas' {MainForm: TUniForm};
 
{$R *.res}
 
{$ifndef UNIGUI_VCL}
exports
  GetExtensionVersion,
  HttpExtensionProc,
  TerminateExtension;
{$endif}
 
begin
{$ifdef UNIGUI_VCL}
  Application.Initialize;
  TUniServerModule.Create(Application);
  Application.Run;
{$endif}
end.

By default, the above project will generate an EXE file, which is an independent server. If you comment out the first line of the project, it will become an ISAPI module (see the instructions and steps below for details). Later, you can convert it back to standalone EXE mode by deleting the comment in the first line. Let’s talk about the methods and steps of mutual conversion.

Steps to convert the combined project to ISAPI DLL:

1) Open the DPR file.
2). Change the first line of the DPR file to (that is, add a “.” after {to comment out the condition of this line): {.$define UNIGUI_VCL}
3). If your Delphi version is XE2 or newer, you need to close the project and reopen it. (If your Delphi version is older than XE2, this step is not required)
4) Build your application.
5). The DLL file will be created in the output folder.

Steps to convert the combined project back to standalone mode:

1) Open the DPR file.
2). Change the first line of the DPR file to: {$define UNIGUI_VCL}
3). If your Delphi version is XE2 or newer, you need to close the project and reopen it. (If your Delphi version is older than XE2, this step is not required)
4) Build your application.
5). The EXE file will be created in the output folder.

4. Windows Services

By creating a uniGUI Windows service application, the application can be deployed as a standard Windows service application. This method is one of the preferred methods for formal use of the environment. Every time the system restarts, the Windows service will run automatically. It will guarantee the availability of web applications. Windows service applications can be accessed from a browser like the standalone server described above, which means that each Windows service application requires a dedicated port (unused dedicated port).

Another deployment method for the formal environment is Windows Services. It created a standard Delphi Windows service project and made some modifications to allow uniGUI ServiceModule to be created. The service project generates standard Windows service executable files, which can be installed like any regular Windows service. The Windows service is automatically started by Windows. As long as Windows is running, you can ensure that it is always available. This provides a high level of usability for uniGUI applications.

program Project1;
 
uses
  SvcMgr,
  ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule},
  MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule},
  Main in 'Main.pas' {MainForm: TUniForm},
  ServiceModule in 'ServiceModule.pas' {UniServiceModule: TUniGUIService};
 
{$R *.res}
 
begin
  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;
  Application.CreateForm(TUniServiceModule, UniServiceModule);
  Application.Run;
end.

Remarks: New programs or projects start from here. The relevant code above is also automatically generated.

Tagscreate uniguidelphiuniguiunigui app
Previous Article

Delphi UniDAC connects to the database via ...

Next Article

UniGUI’s forms and modules

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0
  • 0

admin

Related articles More from author

  • CODE SAMPLESDELPHI

    Build ssl website with Delphi Unigui

    October 23, 2020
    By admin
  • CODE SAMPLESDELPHI

    Two ways to improve the efficiency of unigui development

    October 13, 2020
    By admin
  • DELPHIFIREMONKEY

    Delphi Android APP Automatic Update

    October 31, 2020
    By admin
  • CODE SAMPLESDELPHI

    Delphi calls .net WebService and parameter transfer

    November 28, 2020
    By admin
  • CODE SAMPLESDELPHI

    UniGUI Add CAPTCHA to the WEB project

    January 26, 2021
    By admin
  • CODE SAMPLESDELPHI

    Implementation of uniGUI login-free

    October 9, 2020
    By admin

Leave a reply Cancel reply

You may interested

  • CODE SAMPLESDELPHIFIREMONKEY

    Delphi changes Android brightness

  • CODE SAMPLESDELPHI

    Delphi UniDAC connects to the database via http protocol

  • CODE SAMPLESDELPHI

    TMS WEB CORE designed page layout directly from HTML&CSS

  • LATEST REVIEWS

  • TOP REVIEWS

Timeline

  • January 27, 2021

    How to add a server application written in UNIGUI to startup?

  • January 27, 2021

    UniGUI Expiry Link Anonymizer

  • January 26, 2021

    UniGUI Add CAPTCHA to the WEB project

  • January 26, 2021

    UniGui. Unique hybrid of Delphi and JS

  • January 13, 2021

    How to transform a blob field into string lines (varchar) in SQL Firebird?

Latest Comments

Find us on Facebook

Follow Us on Instagram

logo

Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.

About us

  • 660 Pennsylvania Avenue Southeast #100 Washington, DC 20003
  • 0123456789
  • adsdelphi@gmail.com
  • Recent

  • Popular

  • Comments

  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • UniGUI Expiry Link Anonymizer

    By admin
    January 27, 2021
  • UniGUI Add CAPTCHA to the WEB project

    By admin
    January 26, 2021
  • UniGui. Unique hybrid of Delphi and JS

    By admin
    January 26, 2021
  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • Amazing Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

    By admin
    August 13, 2020
  • Critical Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

    By admin
    September 4, 2020
  • Setting up the IDE for your first Android Application in Delphi

    By admin
    September 7, 2020

Follow us

Find us on Facebook

© Copyright Delphifan Forum. All rights reserved.