PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Renew IP

I know about using this function

IpRenewAddress. But i could not find explantion about this. The explaination at the msdn is very litte.

How someone teach me how to code so that the PDA will release it IP and get a new IP from DHCP server

Thanks in advance
From my reading, you need to call:

Code:
DWORD GetInterfaceInfo(
PIP_INTERFACE_INFO pIfTable,
PULONG dwOutBufLen
);


..to find out what interfaces you have (and their details) in the following structure:

Code:
typedef struct _IP_INTERFACE_INFO {
LONG NumAdapters;
IP_ADAPTER_INDEX_MAP Adapter[1];
} IP_INTERFACE_INFO, *PIP_INTERFACE_INFO;



..., and then call:

Code:
DWORD IpRenewAddress(
PIP_ADAPTER_INDEX_MAP AdapterInfo
);


with the relevant IP_ADAPTER_INDEX_MAP from the _IP_INTERFACE_INFO structure...

Something like (I'm in a rush and my C is embarassingly :oops: rusty so this will not be 100%, esp. with regards to pointers, etc):

Code:
PIP_INTERFACE_INFO if_info;
ulong size=0;
DWORD result;
result=GetInterfaceInfo(NULL,&size);
// check result here


if_info=(PIP_INTERFACE_INFO)malloc(size);
result=GetInterfaceInfo(if_info,&size);
// check result here

result=IpRenewAddress(if_info.Adapter[0]);
// check result here
Code:

PIP_INTERFACE_INFO *if_info;
ulong size=0;
DWORD result;
result=GetInterfaceInfo(NULL,&size;);
// check result here


if_info=(PIP_INTERFACE_INFO *)malloc(size);
result=GetInterfaceInfo(if_info,&size;);
// check result here

result=IpRenewAddress(if_info->Adapter[0]);
// check result here


:)
Thanks Dan. :)

I thought that the "*PIP_INTERFACE_INFO;" on the structure was already defining the PIP_INTERFACE_INFO as a pointer :oops:

Oh well, I'll have some more C practice soon :)
PIP_INTERFACE_INFO if_info;
ulong size=0;
DWORD result;
result=GetInterfaceInfo(NULL,&size;);
// check result here


if_info=(PIP_INTERFACE_INFO)malloc(size);
result=GetInterfaceInfo(if_info,&size;);
// check result here
result=IpRenewAddress(&if;_info->Adapter[0]);

if(result != NO_ERROR)
{
MessageBox(_T("Data Received !!"));
}
else
MessageBox(_T("Data Received 2 !!"));

I execute this code by the reply was
Data Received 2
Ok Thanks its working now .. I misinterpret the if else

Thanks Alot