11. oktober 2001 - 19:12
Der er
1 kommentar og
1 løsning
DLL til mIRC
Hej
jeg er ved at lave lidt scripts til mIRC, og der skal jeg nu til at lave min egen dll!
Så er det jeg vil høre hvordan man skal lave funktioner og procedyre! jeg prøve på det her idag men jeg fik bare en fejl da jeg skulle loade funktionen ind i mIRC!
Er der nogen som gider at lave et eksemple på hvordan man laver en dll, hvor der er en lille funktion og en lille procedyre?
dj
Nybegynder
11. oktober 2001 - 19:27
#1
bemærk at følgende skrives direkte i dpr filen (mIRC_dll.dpr):
-----------------------------
library mIRC_dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library\'s USES clause AND your project\'s (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
classes,
windows,
dialogs,
registry;
var
param: Tstringlist;
procedure Tokenize(text: string; token: char);
var
temp1,temp2: string;
begin
try
param.free;
except
end;
param:=Tstringlist.create;
temp1:=text;
while (Length(temp1) > 0) and (pos(token,temp1)>0) do begin
temp2:=temp1;
temp1 := Copy(temp1, 0, pos(token,temp1)-1);
param.Add(temp1);
temp1 := copy(temp2,pos(token,temp2)+1,length(temp2));
end;
param.Add(temp1);
end;
function ETA( mWnd:
hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause:
Boolean ): Integer;export;stdcall;
begin
strcopy(data, \'The search for E.T. will never end!\');
result:=3;
end;
function RegRead( mWnd:
hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause:
Boolean ): Integer;export;stdcall;
var
mam: pchar;
reg: Tregistry;
key: Hkey;
begin
try
tokenize(data,\'|\');
reg:=Tregistry.create;
if param[0]=\'HKEY_LOCAL_MACHINE\' then
Key:=HKEY_LOCAL_MACHINE;
if param[0]=\'HKEY_CLASSES_ROOT\' then
Key:=HKEY_CLASSES_ROOT;
if param[0]=\'HKEY_CURRENT_USER\' then
Key:=HKEY_CURRENT_USER;
if param[0]=\'HKEY_USERS\' then
Key:=HKEY_USERS;
if param[0]=\'HKEY_CURRENT_CONFIG\' then
Key:=HKEY_CURRENT_CONFIG;
if param[0]=\'HKEY_DYN_DATA\' then
Key:=HKEY_DYN_DATA;
if (param[0] <> \'HKEY_CLASSES_ROOT\') and (param[0] <> \'HKEY_LOCAL_MACHINE\') and
(param[0] <> \'HKEY_CURRENT_USER\') and (param[0] <> \'HKEY_USERS\') and
(param[0] <> \'HKEY_CURRENT_Config\') and (param[0] <> \'HKEY_DYN_DATA\') then begin
Raise Tregistry.create;
end;
reg.RootKey:=key;
reg.OpenKey(param[1],true);
strcopy(data,pchar(reg.ReadString(param[2])));
reg.free;
result:=3;
except
/test3 /echo
/test4 /dll mIRC_DLL.dll RegWrite HKEY_LOCAL_MACHINE|software\\SGUFT Software\\Contact|Skidern|MAM!!
strcopy(data,\'/echo SGUFT_DLL >> 4Failed to read from the registrydatabase! Syntax: $dll(sguft.dll,RegRead, HKEY_LOCAL_MACHINE|software\\SGUFT Software\\Contact|rname)\');
strcopy(parms, \'-s\');
result:=2;
end;
end;
function RegWrite( mWnd:
hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause:
Boolean ): Integer;export;stdcall;
var
mam: pchar;
reg: Tregistry;
key: Hkey;
begin
try
tokenize(data,\'|\');
reg:=Tregistry.create;
if param[0]=\'HKEY_LOCAL_MACHINE\' then
Key:=HKEY_LOCAL_MACHINE;
if param[0]=\'HKEY_CLASSES_ROOT\' then
Key:=HKEY_CLASSES_ROOT;
if param[0]=\'HKEY_CURRENT_USER\' then
Key:=HKEY_CURRENT_USER;
if param[0]=\'HKEY_USERS\' then
Key:=HKEY_USERS;
if param[0]=\'HKEY_CURRENT_CONFIG\' then
Key:=HKEY_CURRENT_CONFIG;
if param[0]=\'HKEY_DYN_DATA\' then
Key:=HKEY_DYN_DATA;
reg.RootKey:=key;
reg.OpenKey(param[1],true);
reg.writeString(param[2],param[3]);
reg.free;
strcopy(data,\'/echo SGUFT_DLL >> 3Info was successfully written to the registrydatabase!\');
strcopy(parms, \'-s\');
result:=2;
except
strcopy(data,\'/echo SGUFT_DLL >> 4Failed to write to the registrydatabase!\');
strcopy(parms, \'-s\');
result:=2;
end;
end;
function ETB( mWnd:
hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause:
Boolean ): Integer;export;stdcall;
var
mam: pchar;
begin
strcopy(mam,pchar( Inputbox(\'Inputbox\',\'Enter somekind of Input?\',\'\')));
strcopy(data, pchar(\'/echo The search for E.T. will never end! | /echo er det mam ? | /echo \'+mam));
strcopy(parms, \'-a\');
result:=2;
end;
exports ETA, ETB, RegRead, RegWrite;
end.
-----------------------
Håber du kan bruge det til noget, der er inkluderet nogle simple funktioner til bl.a. og læse fra og skrive til registreringsdatabasen fra mIRC. Og så derudover ETA og ETB der viser lidt generelt om hvordan man kan udføre funktioner og smide noget mIRC script tilbage som så bliver udført i mIRC.
Mvh. DJ