Using Winhttp lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Timewarp · 2011-09-11 14:47 Hello! This code works fine (in Windows ofcourse) Code: [Select]uses comobj; procedure TForm1.Button1Click(Sender: TObject); var http: variant; begin  http:=createoleobject('WinHttp.WinHttpRequest.5.1');  http.open('GET', 'http://lazarus.freepascal.org', false);  http.send;  showmessage(http.responsetext); end; This doesn't work. I don't understand, only difference is variable s, which contains the URL? Code: [Select]uses comobj; procedure TForm1.Button1Click(Sender: TObject); var http: variant; s: string; begin  s:='http://lazarus.freepascal.org';  http:=createoleobject('WinHttp.WinHttpRequest.5.1');  http.open('GET', s, false);  http.send;  showmessage(http.responsetext); end; I have tried things like ansistring, but it just doesn't accept url. Both of these are okay in Delphi. Any suggestions? ---------------------------------------------------------------------- Arbee · 2011-09-11 15:24 Shouldn't s be declared as a variant i.s.o. a string? ---------------------------------------------------------------------- Timewarp · 2011-09-11 15:58 That works, thanks! I have always used string in delphi. ---------------------------------------------------------------------- JD · 2011-10-22 18:06 Does anyone know how this can be implemented in Linux (without using Indy, Synapse etc)? Thanks, JD ---------------------------------------------------------------------- felipemdc · 2011-10-22 18:25 Quote from: JD on October 22, 2011, 08:06:19 pmDoes anyone know how this can be implemented in Linux (without using Indy, Synapse etc)? Just read the source code of Synapse or lNet, they use UNIX sockets. But I think this is a bad idea. Synapse and LNet are excelent choices for getting a cross-platform sockets libraries and they are really light weight. Why would you want to limit yourself to a platform- dependent solution which is harder to develop? You will just end up reimplementing a stripped down lnet or synapse. ---------------------------------------------------------------------- JD · 2011-10-22 18:39 Quote from: felipemdc on October 22, 2011, 08:25:43 pmQuote from: JD on October 22, 2011, 08:06:19 pmDoes anyone know how this can be implemented in Linux (without using Indy, Synapse etc)? Just read the source code of Synapse or lNet, they use UNIX sockets. But I think this is a bad idea. Synapse and LNet are excelent choices for getting a cross-platform sockets libraries and they are really light weight. Why would you want to limit yourself to a platform- dependent solution which is harder to develop? You will just end up reimplementing a stripped down lnet or synapse. Very good advice. You're right. Thanks a lot. JD ---------------------------------------------------------------------- DavidTh30 · 2017-08-31 15:58 The code depends on where you use. Here you are. -First code for getting the message from device use 'Microsoft.XMLHTTP'.  So you need permission or login.  please note:  My testing device is "FL BT EPA" and "FL BT EPA MP" (communicate using AT language) uses   ...   Variants, comobj, RegExpr;  Function getText(strURL: variant): String; var   xstrResult:variant;   WinHttpReq:variant;   temp:variant; begin   WinHttpReq:=CreateOleObject('Microsoft.XMLHTTP');   temp:=WinHttpReq.Open('GET',strURL,false);   try   WinHttpReq.Send();   xstrResult:= WinHttpReq.responseText;   except     showmessage('Transfer not work');     Exit;   end;   getText:=xstrResult; end;      procedure TForm1.Button1Click(Sender: TObject); var   re: TRegExpr;   strAns:String; begin   re := TRegExpr.Create;   re.Expression := '.*OK.*';   strAns:=getText('http://10.0.0.100/form?at=at*amli=admin');   if re.Exec(strAns) then showmessage('OK') else showmessage('not OK'); end;    -Second code for getting the message from normal HTTP URL by object 'WinHttpRequest.5.1.'  please note:  Direct to WinHttp.WinHttpRequest.5.1 internet URL uses   ...   Variants, comobj, RegExpr;  Function getText2(strURL: variant): String; var   http :variant; begin   http:=createoleobject('WinHttp.WinHttpRequest.5.1');   try   http.open('GET', strURL, false);   http.send;   except     showmessage('Transfer not work');     Exit;   end;   getText2:=http.responsetext; end;    procedure TForm1.Button2Click(Sender: TObject); var   strAns:String;  begin   strAns:=getText2('http://lazarus.freepascal.org');   Showmessage(strAns); end; /:^)