Hi, I have this piece of code in the onJoin event of an Indy IRC Client:
procedure TfrmMain.ircJoin(Sender: TObject; AUser: TIdIRCUser; AChannel: TIdIRCChannel); type TonJoin = function(AUser: TIdIRCUser; AChannel: TIdIRCChannel):String; var Temp:PChar; LibraryID:THandle; proc:pointer; command:String; begin displayEvent(AUser.Nick, 'has joined the chat'); listUsers;
Temp := PChar(ExePath + dll); LibraryID := LoadLibrary(Temp); If LibraryID <> null then begin proc := GetProcAddress(LibraryID, 'onJoin'); if proc <> nil then begin command := TonJoin(proc)(AUser, AChannel); displayChat(irc.Nick, command); irc.Say(currChannel, command); end; freeLibrary(LibraryID); end; end;
It basically allows me to do basic scripting via a DLL. It all works fine except that after this code has ran once, the client appears to ignore any new incoming messages and disconnecting results in a socket error. After a lot of testing and swearing I managed to narrow it down to the FreeLibrary call, if I comment that out then it works perfectly and nothing dies. Is there anything blatently wrong with that code? I can't see it for the life of me.
Red Flag Submitted
Thank you for helping keep Tek-Tips Forums free from inappropriate posts. The Tek-Tips staff will check this out and take appropriate action.
Reply To This Thread
Posting in the Tek-Tips forums is a member-only feature.