0

I'm developing a .dll file (to be more specific a Browser Helper Object - BHO). And I need to receive some settings hosted in one TXT file. To read this TXT file, I'm using IdHTTP, but when I do .get into the TXT address, it just stop everything. I'll paste the code below:

procedure TMyClass.ReadTXT;
  function LoadTxt(HTTP: TidHTTP; Body: TStringList; URLTxt: string): boolean;
    begin
      try
        Body.Text:= HTTP.Get(URLTxt);
        Result := true;
      except
        Result := false;
      end;
    end;
var
  HTTP: TidHTTP;
  Body: TStringList;
  ValidTXT: boolean;
  Line: string;
  i, aux: integer;
begin
  HTTP := TIDHttp.Create(Nil);
  try
    HTTP.ConnectTimeout:= 5000;
    HTTP.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';
    Body := TStringList.Create;
    try
      ValidTXT := false;
      i := 0;
      while (ValidTXT = false) and (i < TXTs.Count) do
        begin
        if (LoadTXT(HTTP, Body, TXTs.Strings[i]) = true) and (Body.Count > 0) then
          begin
...
end;

So in the beginning of this procedure I've a function, to see if I successfully got some TXT, because as you can see I'm using a TStringList called TXTs. So, I add 3 TXTs addresses into this TStringList, and try to connect till find some valid address. But in the first line of the funcion (Body.Text:= HTTP.Get(URLTxt);) it just stops even with a valid TXT address... Someone have a clue about what is happening?


I figured out what's happening. But don't know why... When I set:

HTTP.ConnectTimeout:= 10000;
HTTP.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';

the .Get method don't work... If someone can clarify this to me, i'll be very thankfully.

Kev
  • 118,037
  • 53
  • 300
  • 385
HwTrap
  • 303
  • 1
  • 3
  • 14
  • I think is good to tell that this same procedure is working fine when into one .exe file. It gives this error now that I put inside the .dll of my BHO... – HwTrap Aug 25 '12 at 01:21
  • What do you learn when you attach your debugger? It should easily tell you where your program is hung. – Rob Kennedy Aug 25 '12 at 02:04
  • I'm sorry, but as this is one DLL that attach to Internet Explorer, I just don't know how to use debugger... Will try to find that out. – HwTrap Aug 25 '12 at 02:11
  • There's something strange here... I'm using regsvr32 to register the DLL as BHO. On WinXP, when I put inside the dll this procedure to be used, the regsvr32 stop responding. If I comment this procedure, it register successfully... I just don't understand what's so wrong with this procedure. – HwTrap Aug 25 '12 at 02:40
  • What is the actual value of `URLTxt` when calling `Get()`? Is `ReadTxt()` being called while the DLL's registration code is running? – Remy Lebeau Aug 25 '12 at 04:04

0 Answers0