[PB + DELPHI] The primary application is PB, the operation interface calls DELPHI development DLL

xiaoxiao2021-03-06  40

Demand: Due to recently receiving such a project, Party A requires the function we developed to join the application they originally existing PB development. The only purpose is to have two EXE applications. Solution: Pack the Delphi's application with DLL and then call in PB. Design: First, PB Part 1, create a new non-visual class N_CST_DEMO, we put the calls of the same module in this class. 2. Define the API call. Defines // Handle in Declare --- Local External Functions: It is the handle of the current window; param: other required parameters Subroutine show_demo (ulong handle, string param) library "project1.dll" 3, create a new form W_main. 4. Create a new menu m_dll. 5. Built a menu item is called the test DLL. Write on the CLICKED event:

N_CST_DEMO N_PDA N_PDA = CREATE N_CST_DEMO N_PDA.SHOW_DEMO (Handle (PARENTWINDOW), "ABCD1234") Destroy n_pda

This way our PB part is completed.

Second, Delphi Part 1, create a new DLL Project,

2, create a new form1. save.

3, write the code in Project:

library Project1; uses SysUtils, Forms, Windows, Classes, Controls, Dialogs, Unit1 in 'Unit1.pas' {Form1}, DM in 'DM.pas' {DataModule1: TDataModule}; {$ R * .RES} procedure DLLMain ( Reason: integer); begin case Reason of DLL_PROCESS_ATTACH: begin Application.CreateForm (TDataModule1, DataModule1); end; DLL_PROCESS_DETACH: begin end; DLL_THREAD_ATTACH: begin end; DLL_THREAD_DETACH: begin end; endend; // remember, in a string in Delphi Parameters need to define Procedure Show_Demo (Handle: Thandle; Const Param: THANDLE; Begin // Save DLL) OldHandle: = Application.Handle; // Change the handle of the DLL application. The handle of the window in the PB is to achieve the executable of the DLL and PB belong to an application // effect: After opening the window in the DLL, there will be no more icon Application.Handle: = handle; Application.CreateForm (TForm1, Form1); try Form1.s_param: = StrPas (param); Form1.ShowModal; finally Form1.Free; Application.Handle: = oldHandle; end; end; exports show_demo; begin DllProc: = @ Dllmain; dllmain (DLL_PROCESS_ATTACH) end.4, after compiling, put Projec T1.DLL can be run under the folder of PB.

-------------- January 9, 2005 13:24:02 Joecom (juwuyi)

转载请注明原文地址:https://www.9cbs.com/read-71363.html

New Post(0)