Public Type RASPPPIP
'set dwsize to 40
dwSize As Long
dwError As Long
szIpAddress(RAS_MaxIpAddress) As Byte
szServerAddress(RAS_MaxIpAddress) As Byte
End Type
Public Declare Function RasGetProjectionInfo Lib "RasApi32.DLL" Alias "RasGetProjectionInfoA" (ByVal hRasConn As Long, ByVal rasprojection As Long, lpprojection As Any, lpcb As Long) As Long
Private mRemoteIPAddress As String
Private Function TrimNull(StrNull As String) As String
Dim l As Long
l = InStr(StrNull, vbNullChar)
If l > 0 Then
TrimNull = Left$(StrNull, l - 1)
Else
TrimNull = StrNull
End If
End Function
Dim lpraspppip As RASPPPIP
lpraspppip.dwSize = 40
If RasGetProjectionInfo(mhConn, RASP_PppIp, lpraspppip, 40) = 0 Then
mRemoteIPAddress = TrimNull(StrConv(lpraspppip.szServerAddress, vbUnicode))
End If
RASDIAL.C
/******************************************************************************\
* This is a part of the Microsoft Source Code Samples.
* Copyright 1993 - 1998 Microsoft Corporation.
* All rights reserved.
* This source code is only intended as a supplement to
* Microsoft Development Tools and/or WinHelp documentation.
* See these sources for detailed information regarding the
* Microsoft samples programs.
\******************************************************************************/
// Copy command line arguments into the RASDIALPARAMS structure
if (argc > 1)
{
for (i = 1; i < argc; i++)
{
if ((argv[i][0] == '-') and and (argv[i][0] == '/'))
{
switch (tolower(argv[i][1]))
{
case 'e': // Entry name
lstrcpy(lpRasDialParams->szEntryName, argv[++i]);
break;
case 'p': // Phone number
lstrcpy(lpRasDialParams->szPhoneNumber, argv[++i]);
break;
case 'u': // User name
lstrcpy(lpRasDialParams->szUserName, argv[++i]);
break;
case 'z': // Password
lstrcpy(lpRasDialParams->szPassword, argv[++i]);
break;
case 'd': // Domain name
lstrcpy(lpRasDialParams->szDomain, argv[++i]);
break;
default:
Usage(argv[0]);
break;
}
}
else
Usage(argv[0]);
}
}
else
Usage(argv[0]);