Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Funktion in dll auslagern (https://www.delphipraxis.net/18487-funktion-dll-auslagern.html)

Pseudemys Nelsoni 19. Mär 2004 13:13


Funktion in dll auslagern
 
moin,

kann mir jemand sagen wie ich eine funktion in einer dll auslagere? ich möchte die dll nachher mit mirc aufrufen, also um mal ein beispiel zu nennen, ich möchte der dll einen wert übergeben, sie soll dann den wert multipliziert mit 2 wiedergeben. Das soll nur ein beispiel sein. also wie hätte das auszusehen?

Luckie 19. Mär 2004 13:17

Re: Funktion in dll auslagern
 
Hier das DLL Tutorial bitte durcharbeiten http://www.luckie-online.de/Ablage/Exporte/

Natürlich sind noch die Schnittstellendefinitionen zu mirc zu beachten.

Pseudemys Nelsoni 19. Mär 2004 13:22

Re: Funktion in dll auslagern
 
danke, werd ich tun :)

Pseudemys Nelsoni 20. Mär 2004 14:44

Re: Funktion in dll auslagern
 
das war mir doch zu schwer das tut, aber ich hab den DLL part aus meinem buch gelesen, da wars einfach erklärt :).

Nun aber eine frage, in der mirc hilfe steht folgendes:

Zitat:

Technical notes
This section contains technical information for programmers who want to create DLLs for use with mIRC.

The routine in the DLL being called must be of the form:

int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

mWnd is the handle to the main mIRC window.

aWnd is the handle of the window in which the command is being issued, this might not be the currently active window if the command is being called by a remote script.

data is the information that you wish to send to the DLL. On return, the DLL can fill this variable with the command it wants mIRC to perform if any.

parms is filled by the DLL on return with parameters that it wants mIRC to use when performing the command that it returns in the data variable.

Note: The data and parms variables can each hold 900 chars maximum.

show is FALSE if the . prefix was specified to make the command quiet, or TRUE otherwise.

nopause is TRUE if mIRC is in a critical routine and the DLL must not do anything that pauses processing in mIRC, eg. the DLL should not pop up a dialog.

The DLL can return an integer to indicate what it wants mIRC to do:

0 means that mIRC should /halt processing

1 means that mIRC should continue processing

2 means that it has filled the data variable with a command which it wants mIRC to perform, and has filled parms with the parameters to use, if any, when performing the command.

3 means that the DLL has filled the data variable with the result that $dll() as an identifier should return.

Note: You may need to create a .def file with the procedure names exported when compiling your DLL.


wie setze ich das:

int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

in delphi um?

NicoDE 20. Mär 2004 14:47

Re: Funktion in dll auslagern
 
Zitat:

Zitat von Pseudemys Nelsoni
was ist mWND? das gibts in delphi doch garnicht oder?

Das ist der Name Parameters (kannst Du in Deiner DLL nennen wie Du willst).
In C/C++ sind Parameter und Typ im Sinne der Delphi Language vertauscht.
(HWND mWnd -> mWnd: HWND)

Zitat:

Zitat von Pseudemys Nelsoni
wie setze ich das:

int __stdcall procname(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

in delphi um?

Delphi-Quellcode:
function ProcName(mWnd, aWnd: HWND; data, parms: PAnsiChar; show, nopause: LongBool): Integer; stdcall;
Bzw. PByte statt PAnsiChar, je nach Verwendung.

Pseudemys Nelsoni 20. Mär 2004 14:48

Re: Funktion in dll auslagern
 
sorry, hab meine frage umgeändert, da mir das auch auffiel *G*

Pseudemys Nelsoni 20. Mär 2004 18:44

Re: Funktion in dll auslagern
 
hoi, danke :)

btw: was ist denn ein LongBool? ein langer boolean? :wiejetzt: :mrgreen:

btw²: muss ich nicht noch export; hinter dem stdcall anfügen damit ich auf die funktion der dll zugreifen kann?

NicoDE 20. Mär 2004 18:58

Re: Funktion in dll auslagern
 
Zitat:

Zitat von Pseudemys Nelsoni
was ist denn ein LongBool?

Ein Boolean mit vier (statt einem) Byte.

Zitat:

Zitat von Pseudemys Nelsoni
muss ich nicht noch export; hinter dem stdcall anfügen damit ich auf die funktion der dll zugreifen kann?

Das wäre eine Möglichkeit - oder einen extra Exports-Abschnitt.

Pseudemys Nelsoni 20. Mär 2004 19:06

Re: Funktion in dll auslagern
 
mach ich das mit dem extra abschnitt :)

achja, sorry ich hab noch eine frage dazu, wie kann ich aus PAnsiChar (enthält ja den übergebenen text oder?) nen string machen? ich meine ich muss ja irgendwie das ganze ding auslesen.

ich hatte mal einfach so planlos angefangen:

Delphi-Quellcode:
library registry_dll;

uses
  Windows, registry;

{$R *.res}

function GetKeyValue(mWnd, aWnd: HWND; data, parms: PAnsiChar; show, nopause: LongBool): Integer; stdcall; export;
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;
  with reg do
  begin
    RootKey := // ja wie krieg ich den denn nun :mrgreen:
end;
in "data" muss ein pfad stecken zum Key in der registry, aber keine anung wie ich mit PAnsiChar umzugehen habe, hast du da ne Idee?

btw: Mag zwar sein das das niemand weiss, weil mirc das halt so will und nicht ihr, aber das ergebnis ist ja ein Integer, wie kann ich denn damit text wiedergeben :oops:

NicoDE 20. Mär 2004 19:13

Re: Funktion in dll auslagern
 
Zitat:

Zitat von Pseudemys Nelsoni
wie kann ich aus PAnsiChar (enthält ja den übergebenen text oder?) nen string machen?

StrPas(x)


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:02 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz