DLL i Delphi

0

Biblioteka dll służy do komunikacji przez port COM z serownikiem PLC

Potrzebuje napisać w oparciu o tą bibliotekę program który by zczytywał dane ze sterownika PLC >> Biblioteka produkcji visilogic... "UnCmDrv1.dll"

przykład z basica excel'a...

Dim mComDriver          As UnCmDrv1.clsCommDriver
Dim WithEvents mTimer   As UnCmDrv1.clsTimer

Private Function prvOpenPort() As Boolean
Dim eComParam As tPC_CommSettings  '<<<< zmienna z biblioteki dll

    'Create new instance of the Comm Driver Dll.
    Set mComDriver = New UnCmDrv1.clsCommDriver   '<< tutej mamy
utworzenie jak by klasy w zmiennej mComDriver

    'Configure the connection parameters.
    With eComParam
       .Baudrate = eBR_38400
       .DataBits = eDB_8
       .Parity = eP_None
       .StopBits = eSB_1
       .TimeOut = 500
       .Retries = 3
    End With
    mComDriver.Comm_Autodetect = True    ' na ktorej wykonujemy operacje :/
    mComDriver.ShowCommMessages = True

    'Opens the com.
    prvOpenPort = mComDriver.Comm_Open(Cells(5, 4), eComParam)

End Function

Tu pytanie jak coś podobnego zrobić w delphi ?

0

Wnioskuje ze cos w tym stylu :D :

uses UnCmDrv1;
var
mComDriver : clsCommDriver;  // (lub TclsCommDriver w zaleznosci jak to wyglada w tej bibliotece)
WithEvents mTimer  : clsTimer;

Function prvOpenPort(): Boolean;
var
eComParam : tPC_CommSettings;
begin
    //Create new instance of the Comm Driver Dll.

     mComDriver := TUnCmDrv1.clsCommDriver.Create(...);// tutaj strzelam :)
   //Configure the connection parameters.
    With eComParam do
    begin
       Baudrate := eBR_38400;
       DataBits := eDB_8;
       Parity := eP_None;
       StopBits := eSB_1;
       TimeOut := 500;
       Retries := 3;
    End;
    mComDriver.Comm_Autodetect := True;  //na ktorej wykonujemy operacje :/
    mComDriver.ShowCommMessages := True;

    //Opens the com.
    prvOpenPort := mComDriver.Comm_Open(Cells(5, 4), eComParam)

End;
0

to jest ActiveX więc

  1. rejestrujesz ją w systemie przez regsvr32 nazwa_dll
  2. w delphi klikasz component\import active x controll
  3. szukasz ją na liście
  4. klikasz create unit

masz

0

zarejestrowałem dll w systemie ale nie mogę znaleźć "w delphi klikasz component\import active x controll"

Korzystam z Turbo Delphi... czy w tej wersji jest to możliwe?

0

musisz poszukać w menu czegoś jak import activex albo import type library czy czegoś podobnego

1 użytkowników online, w tym zalogowanych: 0, gości: 1