大家知道,标准ie窗口按ctrl+n打开新窗口,与原先的窗口是共用session的。
那么,怎样让自己写的下载程序也与某个ie窗口共用session?function TDownLoader.DownloadURL(const aUrl: string): Boolean;
var
  hSession: HINTERNET;
  hService: HINTERNET;
  lpBuffer: array[0..1024 + 1] of Char;
  dwBytesRead: DWORD;
  strLog:string;
begin
Result := False;
  //hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
  //hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  hSession := InternetOpen('Microsoft Internet Explorer', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); 
  try
    if Assigned(hSession) then
    begin
      hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);
      if Assigned(hService) then
      BEGIN
        try
          while True do
          begin
            dwBytesRead := 1024;
            InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead);
            if dwBytesRead = 0 then break;
            lpBuffer[dwBytesRead] := #0;
            //Form1.Memo1.Lines.Add(lpBuffer);
            strLog:=strLog+char(13)+char(10)+lpBuffer;
          end;//while
          Result := True;
        finally
          InternetCloseHandle(hService);
        END;//try
      end;//if
    end;//if
  finally
    InternetCloseHandle(hSession);
  end;
  showmessage(
end;