| |

VerySource

 Forgot password?
 Register
Search
View: 834|Reply: 4

How to assign structure parameters

[Copy link]

4

Threads

12

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-3-4 15:30:01
| Show all posts |Read mode
unit Ukq;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class (TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click (Sender: TObject);
  
  private
    {Private declarations}
  public
    {Public declarations}
  end;

type
  TParams = Record
    Port: String [3];
    CtrlID: String [3]; // device number, [1 ~ 127]
    Params: string [250];
  end;

  pparams = ^ TParams;

var
  Form1: TForm1;


implementation

{$ R * .dfm}
function OpenComm (var lParam: pParams; sType: Integer): Integer; stdcall; external 'CM60.dll';
function CloseComm (var lParam: pParams; sType: Integer): Integer; stdcall; external 'CM60.dll';

procedure TForm1.Button1Click (Sender: TObject);
var
  p: pparams;
  sType, ret: Integer;
begin
  sType: = 2100;
  p.Port: = '001';
  p.CtrlID: = '001';

  ret: = OpenComm (p, sType);
    showmessage (inttostr (ret));


  ret: = CloseComm (p, sType);
   p.CtrlID: = '';
    showmessage (inttostr (ret));
 
end;
end.

Edit successfully, when running p.Port: = '001';
  p.CtrlID: = '001'; Access address error occurred
Reply

Use magic Report

4

Threads

12

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

 Author| Post time: 2020-5-17 19:45:01
| Show all posts
Regardless of the dll call, I comment out the call statement is the same
Reply

Use magic Report

0

Threads

25

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-5-18 14:00:01
| Show all posts
New (p)
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-20 17:15:01
| Show all posts
Supplement :)



New (p);
.....
Dispose (p);
Reply

Use magic Report

0

Threads

40

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-5-21 19:00:01
| Show all posts
Congratulations, the problem should be solved
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list