Форум: "Сети";
Текущий архив: 2004.05.02;
Скачать: [xml.tar.bz2];
Внизкак узнать подключен или нет протокол TCP/IP? Найти похожие ветки
← →
knack © (2004-03-09 12:54) [0]Здрасти.
как узнать (какой ключ в реестре Windows XP) подключен или нет протокол TCP/IP?
я нашел:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip
далее идут параметры сетевых карт по идентификаторам...например:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2B8057FE-A9A6-472C-B57E-0F584217647F}
где именно находится статус (установлен/не установлен, подключен/ не подключен) протокола TCP/IP?
← →
Digitman © (2004-03-09 13:30) [1]program NetProtoViewer;
{$APPTYPE CONSOLE}
uses
Windows,
Messages,
ComObj,
SysUtils,
Winsock2;
const
ole32_DLL = "ole32.dll";
FmtOffs = #10#13" ";
var
hWinSock2: THandle;
WSAData: TWSAData;
i,j: Integer;
ProtocolCount: Integer;
BufSize, FlagMask: DWord;
InstProtocols, Protocol: LPWSAProtocol_Info;
tmpstr: string;
tmpwstr: PWideChar;
function StringFromCLSID(const clsid: TGUID; out psz: PWideChar): HResult; stdcall; external ole32_DLL name "StringFromCLSID";
procedure CoTaskMemFree(pv: Pointer); stdcall; external ole32_DLL name "CoTaskMemFree";
begin
hWinSock2:= LoadLibrary(WINSOCK2_DLL);
if hWinSock2 > HINSTANCE_ERROR then begin
WSAStartup($0202, WSAData);
WriteLn("*****************************************************");
WriteLn("************* Network protocols info ****************");
WriteLn("*****************************************************");
WriteLn;
try
BufSize:= 0;
ProtocolCount:= WSAEnumProtocols(nil, nil, BufSize);
if (ProtocolCount <> SOCKET_ERROR) and (WSAGetLastError <> WSAENOBUFS) then
Exit
else begin
InstProtocols:= AllocMem(BufSize);
try
ProtocolCount:= WSAEnumProtocols(nil, InstProtocols, BufSize);
if ProtocolCount <> SOCKET_ERROR then begin
WriteLn("Total network protocols installed : " + IntToStr(ProtocolCount) + #10#13);
WriteLn("**************************************************");
Protocol:= InstProtocols;
for i:= 0 to ProtocolCount - 1 do begin
WriteLn("Protocol name : " + Protocol.szProtocol);
case Protocol.iAddressFamily of
AF_UNSPEC : tmpstr:= "unspecified";
AF_UNIX : tmpstr:= "Local host (pipes or portals)";
AF_INET : tmpstr:= "Internetwork: UDP, TCP, etc.";
AF_IMPLINK : tmpstr:= "ArpaNet imp addresses";
AF_PUP : tmpstr:= "PUP";
AF_CHAOS : tmpstr:= "mit CHAOS";
AF_IPX : tmpstr:= "IPX/SPX or XEROX NS";
AF_OSI : tmpstr:= "OSI";
AF_ECMA : tmpstr:= "European computer manufacturers (ECMA)";
AF_DATAKIT : tmpstr:= "Datakit protocols";
AF_CCITT : tmpstr:= "CCITT protocols, X.25 etc";
AF_SNA : tmpstr:= "IBM SNA";
AF_DECnet : tmpstr:= "DECnet";
AF_DLI : tmpstr:= "Direct data link interface";
AF_LAT : tmpstr:= "LAT";
AF_HYLINK : tmpstr:= "NSC Hyperchannel";
AF_APPLETALK: tmpstr:= "AppleTalk";
AF_NETBIOS : tmpstr:= "NetBios";
AF_VOICEVIEW: tmpstr:= "VoiceView";
AF_FIREFOX : tmpstr:= "FireFox";
AF_BAN : tmpstr:= "Banyan";
AF_ATM : tmpstr:= "Native ATM Services";
AF_INET6 : tmpstr:= "Internetwork Version 6";
AF_CLUSTER : tmpstr:= "Microsoft Wolfpack";
AF_12844 : tmpstr:= "IEEE 1284.4 WG AF";
AF_IRDA : tmpstr:= "IrDA";
AF_NETDES : tmpstr:= "Network Designers OSI & Gateway enabled";
else
tmpstr:= "unknown";
end;
WriteLn("Address family : " + tmpstr);
WriteLn("Protocol version : " + IntToStr(Protocol.iVersion));
case Protocol.iSocketType of
SOCK_STREAM : tmpstr:= "stream socket";
SOCK_DGRAM : tmpstr:= "datagram socket";
SOCK_RAW : tmpstr:= "raw-protocol interface";
SOCK_RDM : tmpstr:= "reliably-delivered message";
SOCK_SEQPACKET : tmpstr:= "sequenced packet stream";
else
tmpstr:= "unknown";
end;
WriteLn("Socket type : " + tmpstr);
WriteLn("MaxSockAddr : " + IntToStr(Protocol.iMaxSockAddr));
WriteLn("MinSockAddr : " + IntToStr(Protocol.iMinSockAddr));
← →
Digitman © (2004-03-09 13:31) [2]if StringFromCLSID(Protocol.ProviderId, tmpwstr) = S_OK then begin
tmpstr:= tmpwstr;
CoTaskMemFree(tmpwstr);
end else
tmpstr:= "unknown";
WriteLn("Provider GUID : " + tmpstr);
// if ((Protocol.dwServiceFlags1 and XP1_QOS_SUPPORTED) = XP1_QOS_SUPPORTED)
// and (Protocol.iSocketType = SocketType)
// and (Protocol.iAddressFamily = AF_INET ) then
tmpstr:= "";
for j:= 0 to 31 do begin
FlagMask:= 1 shl j;
if (Protocol.dwServiceFlags1 and FlagMask) = FlagMask then
case FlagMask of
XP1_CONNECTIONLESS :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "CONNECTIONLESS"; end;
XP1_GUARANTEED_DELIVERY :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "GUARANTEED_DELIVERY"; end;
XP1_GUARANTEED_ORDER :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "GUARANTEED_ORDER"; end;
XP1_MESSAGE_ORIENTED :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "MESSAGE_ORIENTED"; end;
XP1_PSEUDO_STREAM :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "PSEUDO_STREAM"; end;
XP1_GRACEFUL_CLOSE :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "GRACEFUL_CLOSE"; end;
XP1_EXPEDITED_DATA :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "EXPEDITED_DATA"; end;
XP1_CONNECT_DATA :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "CONNECT_DATA"; end;
XP1_DISCONNECT_DATA :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "DISCONNECT_DATA"; end;
XP1_SUPPORT_BROADCAST :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "SUPPORT_BROADCAST"; end;
XP1_SUPPORT_MULTIPOINT :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "SUPPORT_MULTIPOINT"; end;
XP1_MULTIPOINT_CONTROL_PLANE :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "MULTIPOINT_CONTROL_PLANE"; end;
XP1_MULTIPOINT_DATA_PLANE :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "MULTIPOINT_DATA_PLANE"; end;
XP1_QOS_SUPPORTED :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "QOS_SUPPORTED"; end;
XP1_INTERRUPT :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "INTERRUPT"; end;
XP1_UNI_SEND :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "UNI_SEND"; end;
XP1_UNI_RECV :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "UNI_RECV"; end;
XP1_IFS_HANDLES :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "IFS_HANDLES"; end;
XP1_PARTIAL_MESSAGE :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "PARTIAL_MESSAGE"; end;
else
if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs;
tmpstr:= tmpstr + "Unknown($" + IntToHex(FlagMask, 8) + ")";
end;
end;
Write("Service flags 1 : ");
if tmpstr <> "" then
WriteLn(tmpstr)
else
WriteLn("Not specified");
tmpstr:= "";
for j:= 0 to 31 do begin
FlagMask:= 1 shl j;
if (Protocol.dwProviderFlags and FlagMask) = FlagMask then
case FlagMask of
PFL_MULTIPLE_PROTO_ENTRIES :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "MULTIPLE_PROTO_ENTRIES"; end;
PFL_RECOMMENDED_PROTO_ENTRY :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "RECOMMENDED_PROTO_ENTRY"; end;
PFL_HIDDEN :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "HIDDEN"; end;
PFL_MATCHES_PROTOCOL_ZERO :begin if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs; tmpstr:= tmpstr + "MATCHES_PROTOCOL_ZERO"; end;
else
if tmpstr <> "" then tmpstr:= tmpstr + FmtOffs;
tmpstr:= tmpstr + "Unknown($" + IntToHex(FlagMask, 8) + ")";
end;
end;
Write("Provider flags : ");
if tmpstr <> "" then
WriteLn(tmpstr)
else
WriteLn("Not specified");
WriteLn("--------------------------------------------------");
if Succ(i) < ProtocolCount then begin
Write("Press ENTER to continue ...");
ReadLn;
WriteLn;
Inc(Integer(Protocol), SizeOf(TWSAProtocol_Info));
end;
end;
end;
finally
FreeMem(InstProtocols);
end;
end;
finally
WSACleanup;
end;
end else begin
WriteLn("Missing library " + WINSOCK2_DLL);
end;
Write("Press ENTER to exit ...");
ReadLn;
end.
← →
knack © (2004-03-09 15:04) [3]класс - пример!
спасибо большое :)
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2004.05.02;
Скачать: [xml.tar.bz2];
Память: 0.5 MB
Время: 0.037 c