04.05.2011, 12:05
|
|
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
вот всего 66,5 Кб (с upx 31,5 Кб) exe - никаких VCL и вообще uses отсутствуют :
Код:
program XMLHttpRequest;
{$APPTYPE CONSOLE}
type
IXMLHttpRequest = interface(IDispatch)
['{ED8C108D-4349-11D2-91A4-00C04F7969E8}']
procedure open(const bstrMethod: WideString; const bstrUrl: WideString; varAsync: OleVariant;
bstrUser: OleVariant; bstrPassword: OleVariant); safecall;
procedure setRequestHeader(const bstrHeader: WideString; const bstrValue: WideString); safecall;
function getResponseHeader(const bstrHeader: WideString): WideString; safecall;
function getAllResponseHeaders: WideString; safecall;
procedure send(varBody: OleVariant); safecall;
procedure abort; safecall;
function Get_status: Integer; safecall;
function Get_statusText: WideString; safecall;
function Get_responseXML: IDispatch; safecall;
function Get_responseText: WideString; safecall;
function Get_responseBody: OleVariant; safecall;
function Get_responseStream: OleVariant; safecall;
function Get_readyState: Integer; safecall;
procedure Set_onreadystatechange(const Param1: IDispatch); safecall;
property status: Integer read Get_status;
property statusText: WideString read Get_statusText;
property responseXML: IDispatch read Get_responseXML;
property responseText: WideString read Get_responseText;
property responseBody: OleVariant read Get_responseBody;
property responseStream: OleVariant read Get_responseStream;
property readyState: Integer read Get_readyState;
property onreadystatechange: IDispatch write Set_onreadystatechange;
end;
const
CLASS_XMLHTTPRequest: TGUID = '{ED8C108E-4349-11D2-91A4-00C04F7969E8}';
CLSCTX_INPROC_SERVER = 1;
CLSCTX_LOCAL_SERVER = 4;
function CoInitialize(pvReserved: Pointer): HResult; stdcall; external 'ole32.dll';
function CoCreateInstance(const clsid: TGUID; unkOuter: IUnknown;
dwClsContext: Longint; const iid: TGUID; out pv): HResult; stdcall; external 'ole32.dll';
procedure CoUninitialize; stdcall; external 'ole32.dll';
function GetIP: String;
var
xml: IXMLHttpRequest;
begin
CoCreateInstance(CLASS_XMLHTTPRequest, nil, CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IUnknown, xml);
xml.open('GET', 'http://www.whatismyip.com/automation/n09230945.asp', False, '', '');
xml.send('');
if xml.status=200 then Result:=xml.responseText else Result:='';
end;
begin
CoInitialize(nil);
Writeln(GetIP);
Readln;
CoUninitialize;
end.
__________________
Пишу программы за еду.
__________________
|