james henderson
asked on
byte to const char * conversion error
I have the function below. It fails to compile with the following error:
u:\myDll\WinNetTools.c(151
The error is referring to this line:
int iPos = strlen(psClientAddr->Addre
char* pszIP = inet_ntoa(*((struct in_addr *)(&psClientAddr->Address[
Can anyone tell me what I'm doing wrong?
int GetRemoteIP(const DWORD dwASessionID, char* pszIPBuff)
{
int rc = FALSE;
LPTSTR pszBuffer = NULL;
DWORD dwBytes = 0;
if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwASessionID, WTSClientAddress, &pszBuffer, &dwBytes)) {
WTS_CLIENT_ADDRESS* psClientAddr = (WTS_CLIENT_ADDRESS *)pszBuffer;
if (psClientAddr->AddressFamily == AF_INET) {
/* if the return addr contains a port, ignore the port */
int iPos = strlen(psClientAddr->Address) == 4 ? 0 : 2;
char* pszIP = inet_ntoa(*((struct in_addr *)(&psClientAddr->Address[iPos])));
if (pszIP) {
strncpy(pszIPBuff, pszIP, MAX_IPADDR_LENGTH);
pszIPBuff[MAX_IPADDR_LENGTH] = 0;
rc = TRUE;
}
}
WTSFreeMemory(pszBuffer);
}
pszIPBuff[MAX_IPADDR_LENGTH] = '\0';
return rc;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.