I know in Windows CE 6.0 you can change the ip address on the device by
doing the following
1. Navigate to : Start -> Settings -> Control Panel -> Network and
Dial up Connections
2. Right click on the network adapter and select Properties
3. You will see the IP Settings dialog box
4. Click Specify an IP address and fill it in
I would like to do the same thing in a program. What do I wirte too? Are
they registry entries or something in the smbserver.dll? Can someone please
provide some detail on what to write too?
--
Don
showProperties in public\common\oak\drivers\netsamp\connmc\LanConnInfo.cpp
AdapterIPProperties in public\common\oak\drivers\netui\network.c
"Don" <D...@discussions.microsoft.com> wrote in message
news:B49AE3D8-631F-45CE...@microsoft.com...
/**********************************************************************
[HKEY_LOCAL_MACHINE\Comm\SMSC91181\Parms\TcpIp]
"EnableDHCP"=dword:0
"IpAddress"="192.168.0.239"
"Subnetmask"="255.255.255.0"
"DefaultGateway"="192.168.0.1"
"UseZeroBroadcast"=dword:0
"DNS"="202.56.230.5"
**********************************************************************/
// SetAdaptorInfo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include <Iphlpapi.h>
#include "Winsock2.h"
#define IOCTL_NDIS_REBIND_ADAPTER 0x17002e
//IP_ADAPTER_INFO AdapterInfo[4];
typedef struct _ADDRESS_NETWORK
{
TCHAR IP[16];
TCHAR GW[16];
TCHAR SNM[16];
}ADDRESS_NETWORK;
ADDRESS_NETWORK gAddress;
//This will set the Ip address, Gateway address and SubnetMask Address
void SetNetworkRegistry(void)
{
TCHAR szTemp[256];
HKEY hKey;
LONG hRes;
DWORD xcount;
//Copy the Sub Registry key name in to the string
_tcscpy (szTemp, TEXT("Comm\\SMSC91181\\Parms\\TcpIp"));
wcscpy(gAddress.IP,L"192.168.0.118");
wcscpy(gAddress.GW,L"192.168.0.1");
wcscpy(gAddress.SNM,L"255.255.255.0");
hKey = NULL;
//Open the registry Key
hRes = RegOpenKeyEx (HKEY_LOCAL_MACHINE, szTemp, 0, 0, &hKey);
if (ERROR_SUCCESS == hRes && hKey != NULL)
{
// Set the IP Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("IpAddress"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.IP, sizeof(gAddress.IP)) == ERROR_SUCCESS ))
{
wprintf(L"ERROR IN IpAddress OPEN\r\n");
}
// Set the Subnet Mask Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("Subnetmask"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.SNM, sizeof(gAddress.SNM)) == ERROR_SUCCESS ))
{
wprintf(L"ERROR IN Subnetmask OPEN\r\n");
}
// Set the gateway Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("DefaultGateway"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.GW, sizeof(gAddress.GW)) == ERROR_SUCCESS ))
{
wprintf(L"ERROR IN DefaultGateway OPEN\r\n");
}
//Close the Registry Key
RegCloseKey (hKey);
}
//Open the Handle to Rebind the Network Adapter
HANDLE hNdis = CreateFile(_T("NDS0:"), GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL );
if (hNdis == NULL)
{
wprintf(L"ERROR IN CreateFile\r\n");
}
// ULONG Size=sizeof(AdapterInfo);
// GetAdaptersInfo(AdapterInfo,&Size);
TCHAR *str = TEXT("SMSC91181\0") ;
//Rebind the Network Adapter
if (!DeviceIoControl(hNdis, IOCTL_NDIS_REBIND_ADAPTER, str
,(_tcslen(str)+2) * sizeof(TCHAR), NULL, 0, &xcount, NULL ) )
{
//TCHAR str[100];
DWORD Error=::GetLastError();
wprintf(L"ERROR IN DeviceIoControl: %d\r\n",Error);
}
//Close the Handle
CloseHandle(hNdis);
}
int _tmain(int argc, _TCHAR* argv[])
{
SetNetworkRegistry();
return 0;
}
Good Luck.
--
vinoth.R
http://vinoth-vinothblog.blogspot.com
http://www.e-consystems.com
It keeps failing at DeviceIoControl when rebinding the adaptor. Do you have
any suggestions on what I could be doing wrong?
// StaticIP.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include <Iphlpapi.h>
#include "Winsock2.h"
void SetNetworkRegistry(void);
void WriteStringToErrorLog(char *buffer);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
WriteStringToErrorLog("\nWinMain");
SetNetworkRegistry();
return 0;
}
// SetAdaptorInfo.cpp : Defines the entry point for the console application.
//
#define IOCTL_NDIS_REBIND_ADAPTER 0x17002e
//IP_ADAPTER_INFO AdapterInfo[4];
typedef struct _ADDRESS_NETWORK
{
TCHAR IP[16];
TCHAR GW[16];
TCHAR SNM[16];
}ADDRESS_NETWORK;
ADDRESS_NETWORK gAddress;
//This will set the Ip address, Gateway address and SubnetMask Address
void SetNetworkRegistry(void)
{
LPVOID lpMsgBuf;
TCHAR szTemp[256];
HKEY hKey;
LONG hRes;
DWORD xcount;
WriteStringToErrorLog("\nSetNetworkRegistry Called");
_tcscpy (szTemp, TEXT("Comm\\PCI\\FETCE6B1\\Parms\\TcpIp"));
wcscpy(gAddress.IP,L"192.168.1.118");
wcscpy(gAddress.GW,L"192.168.1.1");
wcscpy(gAddress.SNM,L"255.255.255.0");
hKey = NULL;
//Open the registry Key
hRes = RegOpenKeyEx (HKEY_LOCAL_MACHINE, szTemp, 0, 0, &hKey);
if (ERROR_SUCCESS == hRes && hKey != NULL)
{
// Set the IP Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("IpAddress"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.IP, sizeof(gAddress.IP)) == ERROR_SUCCESS ))
{
WriteStringToErrorLog("\nERROR IN IpAddress OPEN");
wprintf(L"ERROR IN IpAddress OPEN\r\n");
}
// Set the Subnet Mask Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("Subnetmask"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.SNM, sizeof(gAddress.SNM)) == ERROR_SUCCESS ))
{
WriteStringToErrorLog("\nERROR IN Subnetmask OPEN");
wprintf(L"ERROR IN Subnetmask OPEN\r\n");
}
// Set the gateway Address Registry Setting
if(!(RegSetValueEx (hKey, TEXT("DefaultGateway"), 0, REG_MULTI_SZ, (const
UINT8*)gAddress.GW, sizeof(gAddress.GW)) == ERROR_SUCCESS ))
{
WriteStringToErrorLog("\nERROR IN DefaultGateway OPEN");
wprintf(L"ERROR IN DefaultGateway OPEN\r\n");
}
//Close the Registry Key
RegCloseKey (hKey);
}
//Open the Handle to Rebind the Network Adapter
HANDLE hNdis = CreateFile(_T("NDS0:"), GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL );
if (hNdis == NULL)
{
WriteStringToErrorLog("\nERROR IN CreateFile");
wprintf(L"ERROR IN CreateFile\r\n");
}
// ULONG Size=sizeof(AdapterInfo);
// GetAdaptersInfo(AdapterInfo,&Size);
TCHAR *str = TEXT("FETCE6B1\0") ;
//Rebind the Network Adapter
if (!DeviceIoControl(hNdis, IOCTL_NDIS_REBIND_ADAPTER, str
,(_tcslen(str)+2) * sizeof(TCHAR), NULL, 0, &xcount, NULL ) )
{
WriteStringToErrorLog("\nERROR IN DeviceIoControl:");
//TCHAR str[100];
DWORD Error=::GetLastError();
wprintf(L"ERROR IN DeviceIoControl: %d\r\n",Error);
}
WriteStringToErrorLog("\nSetNetworkRegistry Retrurned");
//Close the Handle
CloseHandle(hNdis);
}
void WriteStringToErrorLog(char *buffer)
{
int i = 0;
FILE *fptr;
fptr = fopen( "\\Hard Disk2\\StaticIP.txt", "a");
for(i = 0; buffer[i]; i++);
fwrite(buffer,1,i,fptr);
fclose(fptr);
}
--
Don
TCHAR *str = TEXT("PCI\\FETCE6B1\0") ;
"Don" <D...@discussions.microsoft.com> wrote in message
news:2EDD0AF5-816B-4665...@microsoft.com...
TCHAR *str = TEXT("\PCI\AdapterName\0") --
Now that the ip is changed I can no longer browse with Windows Explorer by
type
\\ipaddress
to see my CE device. I can ping from a DOS prompt from another pc on my
network running Windows XP. Do you have any idea why Windows explorer on
another pc would not be able to browse with using the new changed ip
Don
hSrvDev = CreateFile(L"SMB1:",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0, NULL);
DeviceIoControl(hSrvDev,IOCTL_SERVICE_REFRESH,
NULL,0,0,0,0,NULL);
"Don" <D...@discussions.microsoft.com> wrote in message
news:0BDEB720-46EF-4DD7...@microsoft.com...
"KMOS" wrote:
> .
>