Re: [twsocket] DLL implementation advice (or example)...

2011-09-17 Thread Francois PIETTE
I see. The idea is the usage of the widestring just as a easy way to call the, behind the scene, SysAllocString and SysFreeString, that we need in this case. But we can always treat it as a buffer, setting its length, and moving data, explicitly, without casting. In my opinion, it is ALWAYS a

Re: [twsocket] DLL implementation advice (or example)...

2011-09-17 Thread RTT
On 17-09-2011 09:56, Francois PIETTE wrote: I see. The idea is the usage of the widestring just as a easy way to call the, behind the scene, SysAllocString and SysFreeString, that we need in this case. But we can always treat it as a buffer, setting its length, and moving data, explicitly,

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread Arno Garrels
Adam Burgoyne wrote: I've now changed the code to this which should solve the problem if I understood correctly: function ReadMessage: PAnsiChar; stdcall; var Note: AnsiString; begin EnterCriticalSection(CritSectn); if (NotesList.Count 0) then begin Note :=

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread Adam Burgoyne
implementation advice (or example)... Adam Burgoyne wrote: I've now changed the code to this which should solve the problem if I understood correctly: function ReadMessage: PAnsiChar; stdcall; var Note: AnsiString; begin EnterCriticalSection(CritSectn); if (NotesList.Count 0

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread Arno Garrels
: [twsocket] DLL implementation advice (or example)... Adam Burgoyne wrote: I've now changed the code to this which should solve the problem if I understood correctly: function ReadMessage: PAnsiChar; stdcall; var Note: AnsiString; begin EnterCriticalSection(CritSectn

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread RTT
I think you could also use a WideString var parameter. function ReadMessage(var msg:WideString):boolean; stdcall; var Note: AnsiString; begin EnterCriticalSection(CritSectn); if (NotesList.Count 0) then begin msg := NotesList.Strings[0]; NotesList.Delete(0); Result := true; end

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread Arno Garrels
RTT wrote: I think you could also use a WideString var parameter. That would work which plain text, but it's slow.. I bet it's slower than one more copy of the result string. Also using WideString leads to implicit string casts, without any warning in Delphi versions 2009, which is

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread RTT
On 16-09-2011 18:58, Arno Garrels wrote: That would work which plain text Why your reference to plaint text? A WideString can carry any data, or I'm missing something? And WideStrings are now relatively fast, in Vista and 7, if compared to XP. But I really don't know if two calls, one to get

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread Arno Garrels
RTT wrote: On 16-09-2011 18:58, Arno Garrels wrote: That would work which plain text Why your reference to plaint text? A WideString can carry any data, or I'm missing something? As far as I read this thread the OP uses a non-Unicode Delphi version. So string maps to AnsiString. Any

Re: [twsocket] DLL implementation advice (or example)...

2011-09-16 Thread RTT
On 16-09-2011 20:20, Arno Garrels wrote: As far as I read this thread the OP uses a non-Unicode Delphi version. So string maps to AnsiString. Any assignment of an AnsiString to a WideString leads to an implicit string cast to Unicode (Win API WideCharToMultiByte) internally, that's one of the

Re: [twsocket] DLL implementation advice (or example)...

2011-09-15 Thread Wilfried Mestdagh
Hi Adam, despite tearing out some hair and losing a Hopefully you have spare :) Result := PAnsiChar(NotesList.Strings[0]); NotesList.Delete(0); The problem is that you give a pointer to the return value of that function to something that not exists anymore after the functions exit:

Re: [twsocket] DLL implementation advice (or example)...

2011-09-15 Thread Adam Burgoyne
...@elists.org] On Behalf Of Wilfried Mestdagh Sent: 15 September 2011 22:34 To: 'ICS support mailing' Subject: Re: [twsocket] DLL implementation advice (or example)... Hi Adam, despite tearing out some hair and losing a Hopefully you have spare :) Result := PAnsiChar(NotesList.Strings[0

Re: [twsocket] DLL implementation advice (or example)...

2011-09-11 Thread Wilfried Mestdagh
support mailing' Onderwerp: Re: [twsocket] DLL implementation advice (or example)... Hi, Wilfried I'm pleased to say that I've made good progress with the system so far but I'm not sure how to best implement server alternation. Very simply, the current system works with a main server

Re: [twsocket] DLL implementation advice (or example)...

2011-09-09 Thread Wilfried Mestdagh
Hi Adam, The problem is that the DLL is quite unstable so I was trying to use a different approach and hoping to get better stability. Are we talking about TWSocket in your second approach? Right now, I have the basic DLL test project running - it is connecting to my server but the worker

Re: [twsocket] DLL implementation advice (or example)...

2011-09-09 Thread Anton S.
I have an existing DLL that was written to use TClientSocket via a data module. It has a kind of message pump but it works in reverse... it has a timer thread that uses postmessage to trigger the main app to call a ReadData function which checks the socket for received data, then processes it.

Re: [twsocket] DLL implementation advice (or example)...

2011-09-09 Thread Angus Robertson - Magenta Systems Ltd
I'm not a beginner with Delphi but I'm definitely not an expert either so I'm really struggling to create a DLL-based WSocket client that does what I need. I wrote an ActiveX DLL about 10 years ago that's still used on my web site today, doing a reverse DNS look-up on the remote IP address

[twsocket] DLL implementation advice (or example)...

2011-09-08 Thread Adam Burgoyne
Hi - after pulling out a lot of hair, I'm hoping someone can take pity on a poor, struggling programmer who needs some help J I'm not a beginner with Delphi but I'm definitely not an expert either so I'm really struggling to create a DLL-based WSocket client that does what I need. I've

Re: [twsocket] DLL implementation advice (or example)...

2011-09-08 Thread Wilfried Mestdagh
Hi Adam, Hi - after pulling out a lot of hair Hopefully you have some reserve :) I've spent the last couple of days tinkering with the DLL 1 example but DLL is not different from other. Only think is if you write a DLL you maybe don't know who call it. Maybe a programmer will use the DLL