diff --git a/reactos/base/applications/network/ipconfig/En.rc b/reactos/base/applications/network/ipconfig/En.rc new file mode 100644 index 00000000000..b11a14688f9 --- /dev/null +++ b/reactos/base/applications/network/ipconfig/En.rc @@ -0,0 +1,64 @@ + +STRINGTABLE DISCARDABLE +BEGIN + IDS_BCAST "Broadcast" + IDS_P2P "Peer To Peer" + IDS_MIXED "Mixed" + IDS_HYBRID "Hybrid" + IDS_UNKNOWN "unknown" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_OTHER "Other Type Of Adapter" + IDS_ETH "Ethernet Adapter" + IDS_TOKEN "Token Ring Adapter" + IDS_FDDI "FDDI Adapter" + IDS_PPP "PPP Adapter" + IDS_LOOP "Loopback Adapter" + IDS_SLIP "SLIP Adapter" +END + +STRINGTABLE DISCARDABLE +BEGIN +/* Please keep the spacing/formatting as per En.rc when translating */ + IDS_USAGE + "\nUSAGE:\n \ + ipconfig [/? | /all | /renew [adapter] | /release [adapter] |\n \ + /flushdns | /displaydns | /registerdns |\n \ + /showclassid adapter |\n \ + /setclassid adapter [classid] ]\n \ + \n \ + where\n \ + adapter Connection name\n \ + (wildcard characters * and ? allowed, see examples)\n \ + \n \ + Options:\n \ + /? Display this help message\n \ + /all Display full configuration information.\n \ + /release Release the IP address for the specified adapter.\n \ + /renew Renew the IP address for the specified adapter.\n \ + /flushdns Purges the DNS Resolver cache.\n \ + /registerdns Refreshes all DHCP leases and re-registers DNS names.\n \ + /displaydns Display the contents of the DNS Resolver Cache.\n \ + /showclassid Displays all the dhcp class IDs allowed for adapter.\n \ + /setclassid Modifies the dhcp class id.\n \ + \n \ + The default is to display only the IP address, subnet mask and\n \ + default gateway for each adapter bound to TCP/IP.\n \ + \n \ + For Release and Renew, if no adapter name is specified, then the IP address\n \ + leases for all adapters bound to TCP/IP will be released or renewed.\n \ + \n \ + For Setclassid, if no ClassId is specified, then the ClassId is removed.\n \ + \n \ + Examples:\n \ + > ipconfig ... Show information.\n \ + > ipconfig /all ... Show detailed information\n \ + > ipconfig /renew ... renew all adapters\n \ + > ipconfig /renew EL* ... renew any connection that has its\n \ + name starting with EL\n \ + > ipconfig /release *Con* ... release all matching connections,\n \ + eg. ""Local Area Connection 1"" or\n \ + ""Local Area Connection 2""\n" +END diff --git a/reactos/base/applications/network/ipconfig/ipconfig.c b/reactos/base/applications/network/ipconfig/ipconfig.c index 1e377a7e0bf..36750713496 100644 --- a/reactos/base/applications/network/ipconfig/ipconfig.c +++ b/reactos/base/applications/network/ipconfig/ipconfig.c @@ -18,36 +18,101 @@ #include #include #include +#include "resource.h" +#define GUID_LEN 40 + +HINSTANCE hInstance; HANDLE ProcessHeap; -LPCTSTR GetNodeTypeName(UINT NodeType) + +LPTSTR GetNodeTypeName(UINT NodeType) { - switch (NodeType) + static TCHAR szNode[14]; + + switch (NodeType) { - case 1: return _T("Broadcast"); - case 2: return _T("Peer To Peer"); - case 4: return _T("Mixed"); - case 8: return _T("Hybrid"); - default : return _T("unknown"); + case 1: + if (!LoadString(hInstance, IDS_BCAST, szNode, sizeof(szNode))) + return NULL; + break; + + case 2: + if (!LoadString(hInstance, IDS_P2P, szNode, sizeof(szNode))) + return NULL; + break; + + case 4: + if (!LoadString(hInstance, IDS_MIXED, szNode, sizeof(szNode))) + return NULL; + break; + + case 8: + if (!LoadString(hInstance, IDS_HYBRID, szNode, sizeof(szNode))) + return NULL; + break; + + default : + if (!LoadString(hInstance, IDS_UNKNOWN, szNode, sizeof(szNode))) + return NULL; + break; } + + return szNode; } -LPCTSTR GetInterfaceTypeName(UINT InterfaceType) + +LPTSTR GetInterfaceTypeName(UINT InterfaceType) { - switch (InterfaceType) + static TCHAR szIntType[25]; + + switch (InterfaceType) { - case MIB_IF_TYPE_OTHER: return _T("Other Type Of Adapter"); - case MIB_IF_TYPE_ETHERNET: return _T("Ethernet Adapter"); - case MIB_IF_TYPE_TOKENRING: return _T("Token Ring Adapter"); - case MIB_IF_TYPE_FDDI: return _T("FDDI Adapter"); - case MIB_IF_TYPE_PPP: return _T("PPP Adapter"); - case MIB_IF_TYPE_LOOPBACK: return _T("Loopback Adapter"); - case MIB_IF_TYPE_SLIP: return _T("SLIP Adapter"); - default: return _T("unknown"); + case MIB_IF_TYPE_OTHER: + if (!LoadString(hInstance, IDS_OTHER, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_ETHERNET: + if (!LoadString(hInstance, IDS_ETH, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_TOKENRING: + if (!LoadString(hInstance, IDS_TOKEN, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_FDDI: + if (!LoadString(hInstance, IDS_FDDI, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_PPP: + if (!LoadString(hInstance, IDS_PPP, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_LOOPBACK: + if (!LoadString(hInstance, IDS_LOOP, szIntType, sizeof(szIntType))) + return NULL; + break; + + case MIB_IF_TYPE_SLIP: + if (!LoadString(hInstance, IDS_SLIP, szIntType, sizeof(szIntType))) + return NULL; + break; + + default: + if (!LoadString(hInstance, IDS_UNKNOWN, szIntType, sizeof(szIntType))) + return NULL; + break; } + + return szIntType; } + /* print MAC address */ PTCHAR PrintMacAddr(PBYTE Mac) { @@ -59,105 +124,286 @@ PTCHAR PrintMacAddr(PBYTE Mac) return MacAddr; } -DWORD DoFormatMessage(DWORD ErrorCode) + +VOID DoFormatMessage(LONG ErrorCode) { LPVOID lpMsgBuf; - DWORD RetVal; + //DWORD ErrorCode; - if ((RetVal = FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - ErrorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ - (LPTSTR) &lpMsgBuf, - 0, - NULL ))) { + if (ErrorCode == 0) + ErrorCode = GetLastError(); + + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ErrorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ + (LPTSTR) &lpMsgBuf, + 0, + NULL)) + { _tprintf(_T("%s"), (LPTSTR)lpMsgBuf); - LocalFree(lpMsgBuf); - return RetVal; } - else - return 0; } + +LPTSTR GetConnectionType(LPTSTR lpClass) +{ + HKEY hKey = NULL; + LPTSTR ConType = NULL; + TCHAR Path[256]; + LPTSTR PrePath = _T("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\"); + LPTSTR PostPath = _T("\\Connection"); + DWORD PathSize; + DWORD dwType; + DWORD dwDataSize; + + /* don't overflow the buffer */ + PathSize = lstrlen(PrePath) + lstrlen(lpClass) + lstrlen(PostPath) + 1; + if (PathSize >= 255) + return NULL; + + wsprintf(Path, _T("%s%s%s"), PrePath, lpClass, PostPath); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + Path, + 0, + KEY_READ, + &hKey) == ERROR_SUCCESS) + { + if(RegQueryValueEx(hKey, + _T("Name"), + NULL, + &dwType, + NULL, + &dwDataSize) == ERROR_SUCCESS) + { + ConType = (LPTSTR)HeapAlloc(ProcessHeap, + 0, + dwDataSize); + if (ConType == NULL) + return NULL; + + if(RegQueryValueEx(hKey, + _T("Name"), + NULL, + &dwType, + (PBYTE)ConType, + &dwDataSize) != ERROR_SUCCESS) + { + ConType = NULL; + } + } + } + + if (hKey != NULL) + RegCloseKey(hKey); + + return ConType; +} + + +LPTSTR GetConnectionDescription(LPTSTR lpClass) +{ + HKEY hBaseKey = NULL; + HKEY hClassKey = NULL; + LPTSTR lpKeyClass = NULL; + LPTSTR lpConDesc = NULL; + LPTSTR lpPath = NULL; + TCHAR szPrePath[] = _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\"); + DWORD dwType; + DWORD dwDataSize; + INT i; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + szPrePath, + 0, + KEY_READ, + &hBaseKey) != ERROR_SUCCESS) + { + return NULL; + } + + for (i=0; ; i++) + { + DWORD PathSize; + LONG Status; + TCHAR szName[10]; + DWORD NameLen = 9; + + if ((Status = RegEnumKeyEx(hBaseKey, + i, + szName, + &NameLen, + NULL, + NULL, + NULL, + NULL)) != ERROR_SUCCESS) + { + if (Status == ERROR_NO_MORE_ITEMS) + { + DoFormatMessage(Status); + lpConDesc = NULL; + goto CLEANUP; + } + else + continue; + } + + PathSize = lstrlen(szPrePath) + lstrlen(szName) + 1; + lpPath = (LPTSTR)HeapAlloc(ProcessHeap, + 0, + PathSize * sizeof(TCHAR)); + if (lpPath == NULL) + goto CLEANUP; + + wsprintf(lpPath, _T("%s%s"), szPrePath, szName); + + //MessageBox(NULL, lpPath, NULL, 0); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + lpPath, + 0, + KEY_READ, + &hClassKey) != ERROR_SUCCESS) + { + goto CLEANUP; + } + + HeapFree(ProcessHeap, 0, lpPath); + lpPath = NULL; + + if(RegQueryValueEx(hClassKey, + _T("NetCfgInstanceId"), + NULL, + &dwType, + NULL, + &dwDataSize) == ERROR_SUCCESS) + { + lpKeyClass = (LPTSTR)HeapAlloc(ProcessHeap, + 0, + dwDataSize); + if (lpKeyClass == NULL) + goto CLEANUP; + + if(RegQueryValueEx(hClassKey, + _T("NetCfgInstanceId"), + NULL, + &dwType, + (PBYTE)lpKeyClass, + &dwDataSize) != ERROR_SUCCESS) + { + lpKeyClass = NULL; + HeapFree(ProcessHeap, 0, lpKeyClass); + continue; + } + } + else + continue; + + if (!lstrcmp(lpClass, lpKeyClass)) + { + HeapFree(ProcessHeap, 0, lpKeyClass); + lpKeyClass = NULL; + + if(RegQueryValueEx(hClassKey, + _T("DriverDesc"), + NULL, + &dwType, + NULL, + &dwDataSize) == ERROR_SUCCESS) + { + lpConDesc = (LPTSTR)HeapAlloc(ProcessHeap, + 0, + dwDataSize); + if (lpConDesc == NULL) + goto CLEANUP; + + if(RegQueryValueEx(hClassKey, + _T("DriverDesc"), + NULL, + &dwType, + (PBYTE)lpConDesc, + &dwDataSize) != ERROR_SUCCESS) + { + lpConDesc = NULL; + goto CLEANUP; + } + } + else + lpConDesc = NULL; + + break; + } + } + +CLEANUP: + if (hBaseKey != NULL) + RegCloseKey(hBaseKey); + if (hClassKey != NULL) + RegCloseKey(hClassKey); + if (lpConDesc != NULL) + HeapFree(ProcessHeap, 0, lpPath); + if (lpConDesc != NULL) + HeapFree(ProcessHeap, 0, lpKeyClass); + + return lpConDesc; +} + + VOID ShowInfo(BOOL bAll) { PIP_ADAPTER_INFO pAdapterInfo = NULL; PIP_ADAPTER_INFO pAdapter = NULL; ULONG adaptOutBufLen = 0; - PFIXED_INFO pFixedInfo = NULL; - PIP_ADDR_STRING pIPAddr = NULL; ULONG netOutBufLen = 0; - DWORD ErrRet = 0; - - /* assign memory for call to GetNetworkParams */ - pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, sizeof(FIXED_INFO)); - if (pFixedInfo == NULL) + /* call GetAdaptersInfo to obtain the adapter info */ + if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) == ERROR_BUFFER_OVERFLOW) { - _tprintf(_T("memory allocation error")); - return; - } - - /* set required buffer size */ - if(GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW) - { - HeapFree(ProcessHeap, 0, pFixedInfo); - pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen); - if (pFixedInfo == NULL) - { - _tprintf(_T("memory allocation error")); - return; - } - } - - if ((ErrRet = GetNetworkParams(pFixedInfo, &netOutBufLen)) != NO_ERROR) - { - _tprintf(_T("GetNetworkParams failed : ")); - DoFormatMessage(ErrRet); - HeapFree(ProcessHeap, 0, pFixedInfo); - return; - } - - - - /* assign memory for call to GetAdapterInfo */ - pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, sizeof(IP_ADAPTER_INFO)); - if (pAdapterInfo == NULL) - { - _tprintf(_T("memory allocation error")); - return; - } - - /* set required buffer size */ - if (GetAdaptersInfo( pAdapterInfo, &adaptOutBufLen) == ERROR_BUFFER_OVERFLOW) - { - HeapFree(ProcessHeap, 0, pAdapterInfo); pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen); if (pAdapterInfo == NULL) + return; + + if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) != NO_ERROR) { - _tprintf(_T("memory allocation error")); + DoFormatMessage(0); + HeapFree(ProcessHeap, 0, pAdapterInfo); return; } } - - if ((ErrRet = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen)) != NO_ERROR) + else { - _tprintf(_T("GetAdaptersInfo failed : ")); - DoFormatMessage(ErrRet); - HeapFree(ProcessHeap, 0, pAdapterInfo); - return ; + DoFormatMessage(0); + return; } + /* call GetNetworkParams to obtain the network info */ + if(GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW) + { + pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen); + if (pFixedInfo == NULL) + return; + + if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR) + { + DoFormatMessage(0); + HeapFree(ProcessHeap, 0, pFixedInfo); + return; + } + } + else + { + DoFormatMessage(0); + return; + } pAdapter = pAdapterInfo; _tprintf(_T("\nReactOS IP Configuration\n\n")); - if (bAll) { _tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName); @@ -176,7 +422,14 @@ VOID ShowInfo(BOOL bAll) while (pAdapter) { - _tprintf(_T("\n%s ...... : \n\n"), GetInterfaceTypeName(pAdapter->Type)); + LPTSTR IntType, myConType; + + IntType = GetInterfaceTypeName(pAdapter->Type); + myConType = GetConnectionType(pAdapter->AdapterName); + + _tprintf(_T("\n%s %s: \n\n"), IntType , myConType); + + if (myConType != NULL) HeapFree(ProcessHeap, 0, myConType); /* check if the adapter is connected to the media */ if (_tcscmp(pAdapter->IpAddressList.IpAddress.String, "0.0.0.0") == 0) @@ -190,7 +443,7 @@ VOID ShowInfo(BOOL bAll) if (bAll) { - _tprintf(_T("\tDescription . . . . . . . . . . . : %s\n"), pAdapter->Description); + _tprintf(_T("\tDescription . . . . . . . . . . . : %s\n"), GetConnectionDescription(pAdapter->AdapterName)); /// here !! _tprintf(_T("\tPhysical Address. . . . . . . . . : %s\n"), PrintMacAddr(pAdapter->Address)); if (pAdapter->DhcpEnabled) _tprintf(_T("\tDHCP Enabled. . . . . . . . . . . : Yes\n")); @@ -205,22 +458,26 @@ VOID ShowInfo(BOOL bAll) if (bAll) { + PIP_ADDR_STRING pIPAddr; + if (pAdapter->DhcpEnabled) _tprintf(_T("\tDHCP Server . . . . . . . . . . . : %s\n"), pAdapter->DhcpServer.IpAddress.String); _tprintf(_T("\tDNS Servers . . . . . . . . . . . : ")); _tprintf(_T("%s\n"), pFixedInfo->DnsServerList.IpAddress.String); - pIPAddr = pFixedInfo -> DnsServerList.Next; + pIPAddr = pFixedInfo->DnsServerList.Next; while (pIPAddr) { _tprintf(_T("\t\t\t\t\t %s\n"), pIPAddr ->IpAddress.String ); - pIPAddr = pIPAddr ->Next; + pIPAddr = pIPAddr->Next; } + if (pAdapter->HaveWins) { _tprintf(_T("\tPrimary WINS Server . . . . . . . : %s\n"), pAdapter->PrimaryWinsServer.IpAddress.String); _tprintf(_T("\tSecondard WINS Server . . . . . . : %s\n"), pAdapter->SecondaryWinsServer.IpAddress.String); } + if (pAdapter->DhcpEnabled) { _tprintf(_T("\tLease Obtained. . . . . . . . . . : %s"), _tasctime(localtime(&pAdapter->LeaseObtained))); @@ -240,7 +497,6 @@ VOID ShowInfo(BOOL bAll) VOID Release(LPTSTR Index) { IP_ADAPTER_INDEX_MAP AdapterInfo; - DWORD dwRetVal = 0; /* if interface is not given, query GetInterfaceInfo */ if (Index == NULL) @@ -248,39 +504,30 @@ VOID Release(LPTSTR Index) PIP_INTERFACE_INFO pInfo = NULL; ULONG ulOutBufLen = 0; - pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, sizeof(IP_INTERFACE_INFO)); - if (pInfo == NULL) + if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER) { - _tprintf(_T("memory allocation error")); - return; - } - - /* Make an initial call to GetInterfaceInfo to get - * the necessary size into the ulOutBufLen variable */ - if ( GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER) - { - HeapFree(ProcessHeap, 0, pInfo); pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen); if (pInfo == NULL) + return; + + if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR ) { - _tprintf(_T("memory allocation error")); + CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP)); + _tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name); + HeapFree(ProcessHeap, 0, pInfo); + } + else + { + DoFormatMessage(0); + HeapFree(ProcessHeap, 0, pInfo); return; } } - - /* Make a second call to GetInterfaceInfo to get the actual data we want */ - if ((dwRetVal = GetInterfaceInfo(pInfo, &ulOutBufLen)) == NO_ERROR ) - { - CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP)); - _tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name); - } else { - _tprintf(_T("\nGetInterfaceInfo failed : ")); - DoFormatMessage(dwRetVal); + DoFormatMessage(0); + return; } - - HeapFree(ProcessHeap, 0, pInfo); } else { @@ -294,10 +541,10 @@ VOID Release(LPTSTR Index) /* Call IpReleaseAddress to release the IP address on the specified adapter. */ - if ((dwRetVal = IpReleaseAddress(&AdapterInfo)) != NO_ERROR) + if (IpReleaseAddress(&AdapterInfo) != NO_ERROR) { - _tprintf(_T("\nAn error occured while releasing interface %s : "), _T("*name*")); - DoFormatMessage(dwRetVal); + _tprintf(_T("\nAn error occured while releasing interface %S : \n"), AdapterInfo.Name); + DoFormatMessage(0); } } @@ -308,7 +555,6 @@ VOID Release(LPTSTR Index) VOID Renew(LPTSTR Index) { IP_ADAPTER_INDEX_MAP AdapterInfo; - DWORD dwRetVal = 0; /* if interface is not given, query GetInterfaceInfo */ if (Index == NULL) @@ -337,7 +583,7 @@ VOID Renew(LPTSTR Index) } /* Make a second call to GetInterfaceInfo to get the actual data we want */ - if ((dwRetVal = GetInterfaceInfo(pInfo, &ulOutBufLen)) == NO_ERROR ) + if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR ) { CopyMemory(&AdapterInfo, &pInfo->Adapter[0], sizeof(IP_ADAPTER_INDEX_MAP)); _tprintf(_T("name - %S\n"), pInfo->Adapter[0].Name); @@ -345,7 +591,7 @@ VOID Renew(LPTSTR Index) else { _tprintf(_T("\nGetInterfaceInfo failed : ")); - DoFormatMessage(dwRetVal); + DoFormatMessage(0); } HeapFree(ProcessHeap, 0, pInfo); @@ -362,10 +608,10 @@ VOID Renew(LPTSTR Index) /* Call IpRenewAddress to renew the IP address on the specified adapter. */ - if ((dwRetVal = IpRenewAddress(&AdapterInfo)) != NO_ERROR) + if (IpRenewAddress(&AdapterInfo) != NO_ERROR) { _tprintf(_T("\nAn error occured while renew interface %s : "), _T("*name*")); - DoFormatMessage(dwRetVal); + DoFormatMessage(0); } } @@ -373,44 +619,37 @@ VOID Renew(LPTSTR Index) VOID Usage(VOID) { - _tprintf(_T("\nUSAGE:\n" - " ipconfig [/? | /all | /renew [adapter] | /release [adapter] |\n" - " /flushdns | /displaydns | /registerdns |\n" - " /showclassid adapter |\n" - " /setclassid adapter [classid] ]\n" - "\n" - "where\n" - " adapter Connection name\n" - " (wildcard characters * and ? allowed, see examples)\n" - "\n" - " Options:\n" - " /? Display this help message\n" - " /all Display full configuration information.\n" - " /release Release the IP address for the specified adapter.\n" - " /renew Renew the IP address for the specified adapter.\n" - " /flushdns Purges the DNS Resolver cache.\n" - " /registerdns Refreshes all DHCP leases and re-registers DNS names.\n" - " /displaydns Display the contents of the DNS Resolver Cache.\n" - " /showclassid Displays all the dhcp class IDs allowed for adapter.\n" - " /setclassid Modifies the dhcp class id.\n" - "\n" - "The default is to display only the IP address, subnet mask and\n" - "default gateway for each adapter bound to TCP/IP.\n" - "\n" - "For Release and Renew, if no adapter name is specified, then the IP address\n" - "leases for all adapters bound to TCP/IP will be released or renewed.\n" - "\n" - "For Setclassid, if no ClassId is specified, then the ClassId is removed.\n" - "\n" - "Examples:\n" - " > ipconfig ... Show information.\n" - " > ipconfig /all ... Show detailed information\n" - " > ipconfig /renew ... renew all adapters\n" - " > ipconfig /renew EL* ... renew any connection that has its\n" - " name starting with EL\n" - " > ipconfig /release *Con* ... release all matching connections,\n" - " eg. \"Local Area Connection 1\" or\n" - " \"Local Area Connection 2\"\n")); + HRSRC hRes; + LPTSTR lpUsage; + DWORD Size; + + LPTSTR lpName = (LPTSTR)MAKEINTRESOURCE((IDS_USAGE >> 4) + 1); + + hRes = FindResource(hInstance, + lpName, + RT_STRING); + if (hRes != NULL) + { + if ((Size = SizeofResource(hInstance, + hRes))) + { + lpUsage = (LPTSTR)HeapAlloc(ProcessHeap, + 0, + Size); + if (lpUsage == NULL) + return; + + if (LoadString(hInstance, + IDS_USAGE, + lpUsage, + Size)) + { + _tprintf(_T("%s"), lpUsage); + } + } + } + + } int main(int argc, char *argv[]) @@ -425,6 +664,7 @@ int main(int argc, char *argv[]) BOOL DoShowclassid=FALSE; BOOL DoSetclassid=FALSE; + hInstance = GetModuleHandle(NULL); ProcessHeap = GetProcessHeap(); /* Parse command line for options we have been given. */ diff --git a/reactos/base/applications/network/ipconfig/ipconfig.rc b/reactos/base/applications/network/ipconfig/ipconfig.rc index 15ce16298eb..7baf61244de 100644 --- a/reactos/base/applications/network/ipconfig/ipconfig.rc +++ b/reactos/base/applications/network/ipconfig/ipconfig.rc @@ -1,5 +1,13 @@ -#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 ipconfig\0" -#define REACTOS_STR_INTERNAL_NAME "ipconfig\0" -#define REACTOS_STR_ORIGINAL_FILENAME "ipconfig.exe\0" -#define REACTOS_STR_ORIGINAL_COPYRIGHT "Ged Murphy (gedmurphy@gmail.com)\0" +#include +#include +#include "resource.h" + +#define REACTOS_STR_FILE_DESCRIPTION "IP Configuration utility\0" +#define REACTOS_STR_INTERNAL_NAME "ipconfig\0" +#define REACTOS_STR_ORIGINAL_FILENAME "ipconfig.exe\0" +#define REACTOS_STR_ORIGINAL_COPYRIGHT "Ged Murphy + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#include "En.rc" diff --git a/reactos/base/applications/network/ipconfig/resource.h b/reactos/base/applications/network/ipconfig/resource.h new file mode 100644 index 00000000000..fe99c936db7 --- /dev/null +++ b/reactos/base/applications/network/ipconfig/resource.h @@ -0,0 +1,18 @@ + +#define IDS_USAGE 100 + +#define IDS_UNKNOWN 101 + +#define IDS_BCAST 102 +#define IDS_P2P 103 +#define IDS_MIXED 104 +#define IDS_HYBRID 105 + +/* adapter types */ +#define IDS_OTHER 106 +#define IDS_ETH 107 +#define IDS_TOKEN 108 +#define IDS_FDDI 109 +#define IDS_PPP 110 +#define IDS_LOOP 111 +#define IDS_SLIP 112