program SchulServerIP;
{$R *.res}
uses
WinInet, WinSock, Windows;
function LoadURL(
URL:
String):
String;
var
IOpen, IURL: HINTERNET;
Read: Cardinal;
Msg:
array[0..4096]
of Char;
begin
Result := '
';
try
IOpen := InternetOpen('
Delphi-PRAXiS', INTERNET_OPEN_TYPE_PRECONFIG, '
', '
',
INTERNET_FLAG_NEED_FILE);
if IOpen <>
nil then
try
IURL := InternetOpenUrl(IOpen, PAnsiChar(
URL),
nil, 0,
INTERNET_FLAG_NO_UI, 0);
if IURL <>
nil then
try
repeat
FillChar(Msg, SizeOf(Msg), 0);
if InternetReadFile(IURL, @Msg[0], Pred(SizeOf(Msg)),
Read)
then
Result := Result + Msg
else
Break;
until Read = 0;
finally
InternetCloseHandle(IURL);
end;
finally
InternetCloseHandle(IOpen);
end;
except
end;
end;
//http://www.delphipraxis.net/topic6323_http+seite+einlesen+nonvcl.html
procedure CopyTextToClipboard(aWnd: HWND; aText: PChar);
var
Data: THandle;
DataPtr: Pointer;
Size: Integer;
oldWND: HWND;
begin
Size := Length(aText) + 1;
OpenClipboard(aWnd);
//Open Clipboard
try
EmptyClipboard;
// Clear Clipboard
oldWND := SetClipboardViewer(aWnd);
// Clipboard für Programm registr.
Data := GlobalAlloc(GMEM_MOVEABLE
or GMEM_DDESHARE, Size);
// Get Memory
try
DataPtr := GlobalLock(Data);
try
Move(aText^, DataPtr^, Size);
SetClipboardData(CF_TEXT, Data);
// Clpbrd-Format as Text & send Text
finally
GlobalUnlock(Data);
end;
except
GlobalFree(Data);
// Free res. Memory
raise;
// Get global Memory Err
end;
ChangeClipboardChain(aWnd, oldWND);
finally
CloseClipboard;
//Close Clipboard
end;
end;
//http://www.delphipraxis.net/topic73806_nonvcl+send+to+clipboard+as+name+eigenbau.html
var
s:
String;
begin
s := LoadURL('
http://www.lms-sh.de/ip/ip');
while s[Length(s)]
in ['
', #13, #10, #0]
do
SetLength(s, Length(s) - 1);
CopyTextToClipboard(0, PChar(s));
end.