I want to use DhcpGetOptionValue to get option from DHCP server, the result is ERROR_SUCCESS, but lpValue always repoint to NULL, Anyone could help me? thanks so much.
void CDHCPMFCDlg::OnBnClickedButton1()
{
//search scope
DHCP_OPTION_SCOPE_INFO scope;
scope.ScopeType = DhcpDefaultOptions;
scope.ScopeInfo.DefaultScopeInfo = NULL;
scope.ScopeInfo.GlobalScopeInfo = NULL;
//make room for returned value
char * rpStr;
LPDHCP_OPTION_VALUE lpValue = (LPDHCP_OPTION_VALUE)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(DHCP_OPTION_VALUE));
//get value of root path option for client
DWORD readRc = DhcpGetOptionValue(L"127.0.0.1", 3, &scope, &lpValue);
if( readRc != ERROR_SUCCESS)
{
AfxMessageBox(L"FAILED");
}
else
{
CString s = _T("");
if (lpValue == NULL)// it is always TRUE
{
s.Format(_T("Value IS NULL."));
}
else
{
s.Format(_T("%d %d"),lpValue->OptionID,lpValue->Value.NumElements);
}
AfxMessageBox(s);
}
//free returned value, since we have a copy in rpStr
HeapFree(GetProcessHeap(), 0, lpValue);
}
================================================================
My DHCP Server:
Option Name Vendor Value
Class
003 Router Standard 10.30.0.1
None
224 DHCP 224 Standard 10.30.0.1;80;/Manufacturing.DataCenterAgent.XEX;/MfgBootLauncher.xex None