펤imer를 사용해서 알리려면..
관리자만 사용을 하는게 좋을 듯...
만일 전용선 서비스가 중단된 상태에서는 손님들이
불편해 하지 않을 까요?
// uses절에 winsock을 넣으시구...
uses
winsock
function IsOnline: Boolean;
var
Size: Integer;
PC: array[0..4] of Char;
Key: hKey;
function IsIPPresent: Boolean;
type
TaPInAddr = array[0..10] of pInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: array[0..63] of Char;
I: Integer;
GInitData: TWSAData;
IP: string;
begin
WSAStartup($101, GInitData);
Result := False;
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then Exit;
pPtr := PaPInAddr(phe^.h_addr_list);
I := 0;
while pPtr^[I] <> nil do
begin
IP := inet_ntoa(pptr^[I]^);
Inc(I);
end;
WSACleanup;
Result := (IP <> '') and (IP <> '127.0.0.1');
end;
begin
if RegOpenKey(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Services\RemoteAccess', Key) = ERROR_SUCCESS then
begin
Size := 4;
if RegQueryValueEx(Key, 'Remote Connection', nil, nil, @PC, @Size) = ERROR_SUCCESS then
Result := PC[0] = #1
else
Result := IsIPPresent;
RegCloseKey(Key);
end
else
Result := IsIPPresent;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsOnline then begin
showmessage('연결되어있습니다.');
end else begin
showmessage('연결이 끊어진 상태입니다.');
end;
기럼 인천에서 sun.
|