mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Bugfix: we're not Internet Explorer, so stop pretending to be.
This commit is contained in:
@ -7,6 +7,12 @@ uses
|
|||||||
Dialogs, StdCtrls, ExtActns, IniFiles, Controls, Graphics, Registry;
|
Dialogs, StdCtrls, ExtActns, IniFiles, Controls, Graphics, Registry;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TUrlMonUrlMkSetSessionOption = function(dwOption: Cardinal; pBuffer: PChar; dwBufferLength: Cardinal; dwReserved: Cardinal): HRESULT; stdcall;
|
||||||
|
TDownloadUrl2 = class(TDownloadUrl)
|
||||||
|
public
|
||||||
|
procedure SetUserAgent(name: string);
|
||||||
|
end;
|
||||||
|
|
||||||
TfrmUpdateCheck = class(TForm)
|
TfrmUpdateCheck = class(TForm)
|
||||||
btnCancel: TButton;
|
btnCancel: TButton;
|
||||||
groupBuild: TGroupBox;
|
groupBuild: TGroupBox;
|
||||||
@ -22,7 +28,7 @@ type
|
|||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
CheckfileDownload : TDownLoadURL;
|
CheckfileDownload : TDownLoadURL2;
|
||||||
ReleaseURL, BuildURL : String;
|
ReleaseURL, BuildURL : String;
|
||||||
procedure Status(txt: String);
|
procedure Status(txt: String);
|
||||||
procedure ReadCheckFile;
|
procedure ReadCheckFile;
|
||||||
@ -44,6 +50,23 @@ uses helpers, main;
|
|||||||
{$I const.inc}
|
{$I const.inc}
|
||||||
|
|
||||||
|
|
||||||
|
procedure TDownloadUrl2.SetUserAgent(name: string);
|
||||||
|
const
|
||||||
|
UrlMonLib = 'URLMON.DLL';
|
||||||
|
sUrlMkSetSessionOptionA = 'UrlMkSetSessionOption';
|
||||||
|
URLMON_OPTION_USERAGENT = $10000001;
|
||||||
|
var
|
||||||
|
UrlMonHandle: HMODULE;
|
||||||
|
UrlMkSetSessionOption: TUrlMonUrlMkSetSessionOption;
|
||||||
|
begin
|
||||||
|
UrlMonHandle := LoadLibrary(UrlMonLib);
|
||||||
|
if UrlMonHandle = 0 then raise Exception.Create('Could not get handle to urlmon.dll.');
|
||||||
|
UrlMkSetSessionOption := GetProcAddress(UrlMonHandle, PChar(sUrlMkSetSessionOptionA));
|
||||||
|
if not Assigned(UrlMkSetSessionOption) then raise Exception.Create('Could not get handle to UrlMonUrlMkSetSessionOption().');
|
||||||
|
// TODO: Rumoured to be broken in IE8, test when it hits the stores.
|
||||||
|
if UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, PChar(name), Length(name), 0) <> 0 then raise Exception.Create('Could not set User-Agent via UrlMonUrlMkSetSessionOption().');
|
||||||
|
end;
|
||||||
|
|
||||||
{**
|
{**
|
||||||
Set defaults
|
Set defaults
|
||||||
}
|
}
|
||||||
@ -82,7 +105,8 @@ begin
|
|||||||
memoBuild.Clear;
|
memoBuild.Clear;
|
||||||
|
|
||||||
// Prepare download
|
// Prepare download
|
||||||
CheckfileDownload := TDownLoadURL.Create(Self);
|
CheckfileDownload := TDownLoadURL2.Create(Self);
|
||||||
|
CheckfileDownload.SetUserAgent(APPNAME + ' ' + APPVERSION + ' ' + APPREVISION + ' update checker tool');
|
||||||
CheckfileDownload.URL := APPDOMAIN + 'updatecheck.php';
|
CheckfileDownload.URL := APPDOMAIN + 'updatecheck.php';
|
||||||
CheckfileDownload.Filename := GetTempDir + APPNAME + '_updatecheck.ini';
|
CheckfileDownload.Filename := GetTempDir + APPNAME + '_updatecheck.ini';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user