Einzelnen Beitrag anzeigen

st.w

Registriert seit: 5. Jan 2016
11 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#2

AW: Kurze Hilfestellung bei Funktionsaufruf für DDE benötigt

  Alt 21. Jun 2016, 10:03
Hier ein Ausschnitt aus dem Code - Leider klappt die Code-Formattierung bei mir nicht...


unit Unit1;
...
uses ..., DDEObjec, DDEML;

type
TForm1 = class(TForm)
...
private
public
end;

function DdeDataChange(CallType, Fmt: UINT; Conv: HConv; hsz1, hsz2: HSZ; Data: HDDEData; Data1, Data2: DWORD): HDDEData; stdcall;
var Form1: TForm1;
implementation

{$R *.DFM}

var count: Integer = 0;
dde: TDDEMLClass;

function DdeDataChange(CallType, Fmt: UINT; Conv: HConv; hsz1, hsz2: HSZ; Data: HDDEData; Data1, Data2: DWORD): HDDEData;
var str:String;
begin
dde.GetDataAsStrObj(data, str);
Form1.Memo1.Lines.Add(str);
//result := data; eine Result darf ich nicht zurückgen, der DDE-Server meldet sonst einen Timeout?!?
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
dde := TDDEMLClass.Create(DDEDataChange, 0);
dde.Connect(PAnsiChar(edtService.Text), PAnsiChar(edtTopic.Text));
dde.Execute(PAnsiChar(edtMacro.Text));

// HIER BRAUCHE ICH DIE FUNKTIONSAUFRUFE
end;
end.


// Der Anfang der Unit DDEObjec:


{+------------------------------------------------------------
| Unit DDEObjec
| Version: 2.0 Created: 12/18/96, 12:58:02 Last Modified: 12/18/96, 12:58:02
| Author : P. Below
| Project: Common utilities
| Description: Simple DDEML interface for Delphi 2.0
+------------------------------------------------------------}
Unit DDEObjec;

Uses Windows, DDEML, SysUtils, ErrClass;

Type
EDDEMLException = Class( Exception );

TDDEMLClass = Class( TErrClass )
private
f_Inst: LongInt; (* ddeml instance *)
f_Conv: HConv; (* conversation handle *)
f_Server: HSz; (* server name string handle *)
f_Topic : HSz; (* topic name string handle *)
f_Timeout: LongInt; (* timeout for transactions *)
f_LastResult: LongInt; (* last transaction result *)
f_LastError : LongInt; (* last dde error status *)
f_CallbackInst: TFNCallback; (* callback for this instance *)
f_codepage : Integer; (* default code page to use *)

protected
public
Constructor Create( aCallback: TFNCallback; flags : LongInt );
Destructor Destroy; override;

Function MakeHSz( aStr: PChar ): HSz;
Procedure FreeHSz( Var aHSz: HSz );
Function CompareHSz( HSz1, HSz2: HSz ): Integer;
Function QueryHSz( aHSz: HSz; Var aStrObj: String ): Boolean;

Function Connect( aServer, aTopic: PChar): Boolean;
Procedure Disconnect;
Function ClientTransaction( pServerData: Pointer; dataSize: LongInt; Item: HSz; Format, DataType: UINT ): HDDEData;
Function Request( Item: PChar; Format:UINT ): HDDEData;
Function Execute( command: PChar ): Boolean;
Function GetData( hData: hDDEData; buf: Pointer; bufSize, offset: LongInt ): LongInt;
Function GetDataAsStrObj( hData: hDDEData; Var aStrObj: String ): Boolean;
Procedure FreeDatahandle( hData: hDDEData );
Function CreateDataHandle( source: Pointer; len, offset: LongInt; item: HSz; Format, Command: UINT): hDDEData;
Function AddData( data: hDDEData;source: Pointer; len, offset: LongInt ): hDDEData;
Function AccessData( data: hDDEData; DataSize: PDWORD ): Pointer;
Procedure UnaccessData( data: hDDEData );

Function IsConnected: Boolean;
Function IsValid: Boolean;

Procedure DDE_Error;
Procedure SetDDE_Error( err: Longint );

property Timeout: LongInt read f_timeout write f_timeout;
property LastDdeError: LongInt read f_lasterror;
property LastDdeResult: LongInt read f_lastresult;
property Server: HSz read f_server;
property Topic: HSz read f_topic;
property Codepage: Integer read f_codepage write f_codepage;

End;
...
  Mit Zitat antworten Zitat