Lease Obtained/Lease Expires time does not match with Windows 7 OS when "ipconfig /renew" command is executed.
Hi,
I have an MFC application that displays the network adapter details.(For Ex: IP Address, DHCP Server, Lease Obtained, Lease Expires etc.) I have used WMI to get the network adapter details in my application. Following is the code snippet:
IEnumWbemClassObject *l_pWmiEnumerator = NULL;
IWbemClassObject *l_pClsObj = NULL;
...
Execute the following query "SELECT * from Win32_NetworkAdapterConfiguration where index=7"
...
//Get the value of DHCP Lease Obtained
CString l_csDHCPLeaseObtained=_T("");
l_hr=l_pClsObj->Get(_T("DHCPLeaseObtained"),0,&l_vtProp,0,0);
if(VT_NULL!=l_vtProp.vt)
{
//Sets the DHCP Lease Obtained value
}
//Get the value of DHCP Lease expires
CString l_csDHCPLeaseExpires=_T("");
l_hr=l_pClsObj->Get(_T("DHCPLeaseExpires"),0,&l_vtProp,0,0);
if(VT_NULL!=l_vtProp.vt)
{
//Sets the DHCP Lease Expires value
}
Now, when I restart the machine and execute the above code, following values are seen as output in my application on both Windows 7 and Windows XP OS. Also, it matches with the result shown when "ipconfig /all" command is executed on cmd.exe.
Output in my MFC Application:
Lease Obtained: 7/8/2011 3:55:07 PM
Lease Expires: 7/15/2011 3:55:07 PM
Output in cmd.exe:
Lease Obtained: Friday, July 08, 2011 3:55:07 PM
Lease Expires: Friday, July 15, 2011 3:55:07 PM
However, if now I execute the command "ipconfig \renew" from cmd.exe on Windows 7 OS, following output is shown in my application:
Output in my MFC Application:
Lease Obtained: 7/8/2011 4:00:35 PM
Lease Expires: 7/15/2011 4:00:35 PM
Output in cmd.exe:
Lease Obtained: Friday, July 08, 2011 3:55:07 PM
Lease Expires: Friday, July 15, 2011 4:00:35 PM
Can anybody please let me know why the "Lease Obtained" time obtained in my application does not match with that on Windows 7 OS? Also, this problem occurs only in Windows 7 OS and it works fine in Windows XP OS.
Thanks & Regards,
Ruhee Jaiswal
July 13th, 2011 1:12am