GET ADSL IP

Everything else that doesn't fall into one of the other PB categories.
callroot
User
User
Posts: 64
Joined: Sat Mar 05, 2016 10:46 pm

GET ADSL IP

Post by callroot »

Code: Select all


Structure RASCONN
    dwSize.l
    hRasConn.l
    szEntryName.b[256+1]
    szDeviceType.b[16+1]
    szDeviceName.b[128+1]
EndStructure

Structure RASCONNSTATUS
    dwSize.l
    RasConnState.l
    dwError.l
    szDeviceType.b[16+1]
    szDeviceName.b[128+1]
 EndStructure
 
Structure RASDIALPARAMS
  dwSize.l
  szEntryName.b[256 + 1]
  szPhoneNumber.b[128 + 1]
  szCallbackNumber.b[128 + 1]
  szUserName.b[256 + 1]
  szPassword.b[256 + 1]
  szDomain.b[15 + 1]
EndStructure


Structure RASPPPIP 
  dwSize.l
  dwError.l
  szIpAddress.b[15+1]
  szServerIpAddress.b[15+1]
  dwOptions.l
  dwServerOptions.l
EndStructure


Procedure.S GETADSLIP();GET  ADSL IP
  Protected dwSize.l,RASpppIPs.RASPPPIP,Dim lprasconn.RASCONN(255),lpcConnections.l,lpcb.l,lngRetCode.l
  lprasconn(0)\dwSize = 412
  lpcb = 256 * lprasconn(0)\dwSize  
  lngRetCode = RasEnumConnections_(@lprasconn(0), @lpcb, @lpcConnections)
  Debug lngRetCode
  Debug lprasconn(0)\hRasConn
  Debug SizeOf(RASpppIP)
  dwSize=SizeOf(RASpppIP)
  pp=$08021
  Debug RasGetProjectionInfo_(lprasconn(0)\hRasConn,pp,@RASpppIPs,@dwSize)
  
  
EndProcedure

 GETADSLIP();  ret  632
Error return 632



What reason
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: GET ADSL IP

Post by DarkDragon »

https://msdn.microsoft.com/de-de/librar ... s.85).aspx
ERROR_INVALID_SIZE: The dwSize member of the structure pointed to by lpprojection specifies an invalid size.
bye,
Daniel
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: GET ADSL IP

Post by netmaestro »

Try it like this for fun:

Code: Select all

Import "Rasapi32.lib"
  RasEnumConnectionsA(*buffer, *pointer1, *pointer2) 
EndImport

#RAS_MaxEntryName  = 256
#RAS_MaxDeviceName = 128
#Ras_MaxDeviceType = 16

Structure RASCONN
    dwSize.l
    hRasConn.l
    szEntryName.b[#RAS_MaxEntryName+1]
    szDeviceType.b[#Ras_MaxDeviceType+1]
    szDeviceName.b[#RAS_MaxDeviceName+1]
    szPhonebook.b[#MAX_PATH]
    dwSubEntry.l
    guidEntry.GUID
    dwFlags.l
    luid.LUID
    guidCorrelationId.GUID
EndStructure
Remember to change RasEnumConnections_() later in your code to RasEnumConnectionsA()

The reason I suggest the import is I'm not sure if the sz_ members in the structure need to be .u or not as PB 5.5 is linking RasEnumConnectionsW for the native import, but with RasEnumConnectionsA what I have here should be right. Just remember to PeekS() them as #PB_Ascii if you ever get some useful information returned.
BERESHEIT
callroot
User
User
Posts: 64
Joined: Sat Mar 05, 2016 10:46 pm

Re: GET ADSL IP

Post by callroot »

netmaestro wrote:Try it like this for fun:

Code: Select all

Import "Rasapi32.lib"
  RasEnumConnectionsA(*buffer, *pointer1, *pointer2) 
EndImport

#RAS_MaxEntryName  = 256
#RAS_MaxDeviceName = 128
#Ras_MaxDeviceType = 16

Structure RASCONN
    dwSize.l
    hRasConn.l
    szEntryName.b[#RAS_MaxEntryName+1]
    szDeviceType.b[#Ras_MaxDeviceType+1]
    szDeviceName.b[#RAS_MaxDeviceName+1]
    szPhonebook.b[#MAX_PATH]
    dwSubEntry.l
    guidEntry.GUID
    dwFlags.l
    luid.LUID
    guidCorrelationId.GUID
EndStructure
Remember to change RasEnumConnections_() later in your code to RasEnumConnectionsA()

The reason I suggest the import is I'm not sure if the sz_ members in the structure need to be .u or not as PB 5.5 is linking RasEnumConnectionsW for the native import, but with RasEnumConnectionsA what I have here should be right. Just remember to PeekS() them as #PB_Ascii if you ever get some useful information returned.





Code: Select all

Procedure.S GETADSLIP();GET  ADSL IP
  Protected dwSize.l,RASpppIPs.RASPPPIP,Dim lprasconn.RASCONN(255),lpcConnections.l,lpcb.l,lngRetCode.l,rval.l,erro.l
  lprasconn(0)\dwSize = 412
  lpcb = 256 * lprasconn(0)\dwSize  
  lngRetCode = RasEnumConnections_(@lprasconn(0), @lpcb, @lpcConnections)
  dwSize=SizeOf(RASpppIPs)
  RASpppIPs\dwSize =dwSize
  base1:
  rval = RasGetProjectionInfo_(lprasconn(0)\hRasConn,$08021,@RASpppIPs,@dwSize)
  If  rval <> 0
    erro=erro+1
    If erro=3:ProcedureReturn "" : EndIf
    Delay(100)
    Goto base1:
  EndIf
 ProcedureReturn PeekS(@RASpppIPs\szIpAddress)
EndProcedure

 RASpppIPs\dwSize =dwSize  
Specified size is now normal, thank you

__________________________________________________
Code tags added
04.12.2016
RSBasic
callroot
User
User
Posts: 64
Joined: Sat Mar 05, 2016 10:46 pm

Re: GET ADSL IP

Post by callroot »

DarkDragon wrote:https://msdn.microsoft.com/de-de/librar ... s.85).aspx
ERROR_INVALID_SIZE: The dwSize member of the structure pointed to by lpprojection specifies an invalid size.

thank you
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: GET ADSL IP

Post by nco2k »

you dont need to import RasEnumConnectionsA, your structures are wrong!

Code: Select all

#RAS_MaxEntryName = 256
#RAS_MaxDeviceType = 16
#RAS_MaxDeviceName = 128
#RAS_MaxPhoneNumber = 128
#RAS_MaxCallbackNumber = 128
#RAS_MaxIpAddress = 15

#PWLEN = 256
#DNLEN = 15

Structure RASCONN Align #PB_Structure_AlignC
  dwSize.l
  hrasconn.l
  szEntryName.c[#RAS_MaxEntryName + 1]
  szDeviceType.c[#RAS_MaxDeviceType + 1]
  szDeviceName.c[#RAS_MaxDeviceName + 1]
  szPhonebook.c[#MAX_PATH]
  dwSubEntry.l
  guidEntry.GUID
  dwFlags.l
  luid.LUID
  guidCorrelationId.GUID
EndStructure

Structure RASTUNNELENDPOINT Align #PB_Structure_AlignC
  dwType.l
  StructureUnion
  ipv4.b[4]
  ipv6.b[16]
  EndStructureUnion
EndStructure

Structure RASCONNSTATUS Align #PB_Structure_AlignC
  dwSize.l
  rasconnstate.l
  dwError.l
  szDeviceType.c[#RAS_MaxDeviceType + 1]
  szDeviceName.c[#RAS_MaxDeviceName + 1]
  szPhoneNumber.c[#RAS_MaxPhoneNumber + 1]
  localEndPoint.RASTUNNELENDPOINT
  remoteEndPoint.RASTUNNELENDPOINT
  rasconnsubstate.l
EndStructure

Structure RASDIALPARAMS Align #PB_Structure_AlignC
  dwSize.l
  szEntryName.c[#RAS_MaxEntryName + 1]
  szPhoneNumber.c[#RAS_MaxPhoneNumber + 1]
  szCallbackNumber.c[#RAS_MaxCallbackNumber + 1]
  szUserName.c[#UNLEN + 1]
  szPassword.c[#PWLEN + 1]
  szDomain.c[#DNLEN + 1]
  dwSubEntry.l
  *dwCallbackId.Long
  dwIfIndex.l
  *szEncPassword.String
EndStructure

Structure RASPPPIP Align #PB_Structure_AlignC
  dwSize.l
  dwError.l
  szIpAddress.c[#RAS_MaxIpAddress + 1]
  szServerIpAddress.c[#RAS_MaxIpAddress + 1]
  dwOptions.l
  dwServerOptions.l
EndStructure
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Post Reply