Link to home
Start Free TrialLog in
Avatar of james henderson
james hendersonFlag for United States of America

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): error C2664: 'strlen' : cannot convert parameter 1 from 'BYTE [20]' to 'const char *'

The error is referring to this line:
   int iPos = strlen(psClientAddr->Address) == 4 ? 0 : 2;
   char* pszIP = inet_ntoa(*((struct in_addr *)(&psClientAddr->Address[iPos])));


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;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of flob9
flob9
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial