mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2003
Posts: 4
R
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2003
Posts: 4
i have a problem when i run a dll two times.
Mirc close itself, when I start the second run befor the first one was finshed.

an simple example:
I wrote the the following dll just for testing. You can download this dll here.

the source code you can see here (its written in delphi6):

Code:
  
ibrary test;

uses
  SysUtils,
  Windows,
  Forms;

{$R *.res}

type
  TLoadInfo = packed record
    mVersion: DWORD;
    mHwnd: HWND;
    mKeep: Boolean;
  end;
  PLoadInfo = ^TLoadInfo;

procedure Delay(ATime: Cardinal);
var Start: Cardinal;
begin
  Start := GetTickCount;
  repeat
    Application.ProcessMessages;
  until GetTickCount - Start > ATime;
end;

procedure LoadDll(LoadInfo: PLoadInfo); stdcall; export;
begin
  LoadInfo.mKeep := FALSE;
end;

procedure UnloadDll(mTimeOut: integer); stdcall; export;
begin
end;

function teststuff(mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause: Boolean): integer; export; stdcall;
begin
  delay(2000);
  result:=1;
end;

exports
  LoadDll,
  UnloadDll,
  teststuff;

begin
end.


when i progress '/dll test.dll teststuff nothing' two times (or more) in two seconds (cause 'delay(2000);') then mIRC will output an error and close itself.

anyone knows how i can use a dll while the same dll is in progress?

thx anyway .. Frank

Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Thats a limitation of Windows, not of mIRC. A dll can only be loaded into memory once by a program.

Joined: Aug 2003
Posts: 4
R
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2003
Posts: 4
well .. thanks

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Wow, i haven't seen Pascal/Delphi in ages.. Good to see some people stick with the classics >:D


-KingTomato
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Btw though,
function teststuff(mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause: Boolean): integer; export; stdcall;
begin
delay(2000);
result:=1;
end;

That's wrong, (forgive me if my correction isn't right, it's been a while since I touched Pascal/Delphi):

function teststuff(mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar; Show: Boolean; NoPause: Boolean): integer; export; stdcall;
begin
if (not (NoPause = 1)) then
delay(2000);
result:=1;
end;

In case that's not right, let me explain what it does. If NoPause is true, then mIRC is saying "I'm busy, don't do anything that will take a lot of time" to a computer, 2 seconds is a lot of time. So if NoPause = 1, then you can't call delay.

Joined: Aug 2003
Posts: 4
R
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Aug 2003
Posts: 4
well,
'delay' in "old" pascal is similar to sleep in delphi .. sleep holds the programm/dll.

The delay procedure in my dll do 'Application.ProcessMessages;' for the time you specify. This let all other functions/procedures/events in the programm/dll go on progessing (and of cause in all other programs (mIRC) too). It just hold the procedure/function where you use the delay "command".
So in this special example mIRC will go on working the 2 seconds. Otherwise (if mIRC would hold up progressing) it wouldnt be possible to run the dll a second one befor the first one was finished.

The procedurename "delay" in this dll is confusing, sorry

bye .. Frank

Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Ah ok, yeah like I said it's been a long time since I worked with that language smile


Link Copied to Clipboard