Page 4 of 4

Posted: Fri Oct 10, 2003 3:20 pm
by PureUser
I was said that rasdialcallback solves the trouble with window...

Posted: Thu Mar 04, 2004 8:02 pm
by freedimension
OK, this thread is old, I know.
But at the moment I'm online using this code (based upon the code posted here earlier):

Code: Select all

#RAS_MaxEntryName = 256
#RAS_MaxPhoneNumber = 128
#RAS_MaxCallbackNumber = 128
#UNLEN = 256
#PWLEN = 256
#DNLEN = 15

#RAS_MaxDeviceType = 16
#RAS_MaxDeviceName = 128


#RASCS_PAUSED = 4096
#RASCS_DONE = 8192

Enumeration
  #RASCS_OpenPort = 0
  #RASCS_PortOpened
  #RASCS_ConnectDevice
  #RASCS_DeviceConnected
  #RASCS_AllDevicesConnected
  #RASCS_Authenticate
  #RASCS_AuthNotify
  #RASCS_AuthRetry
  #RASCS_AuthCallback
  #RASCS_AuthChangePassword
  #RASCS_AuthProject
  #RASCS_AuthLinkSpeed
  #RASCS_AuthAck
  #RASCS_ReAuthenticate
  #RASCS_Authenticated
  #RASCS_PrepareForCallback
  #RASCS_WaitForModemReset
  #RASCS_WaitForCallback
  #RASCS_Projected
  #RASCS_StartAuthentication
  #RASCS_CallbackComplete
  #RASCS_LogonNetwork
  #RASCS_SubEntryConnected
  #RASCS_SubEntryDisconnected
  #RASCS_Interactive = #RASCS_PAUSED 
  #RASCS_RetryAuthentication = #RASCS_PAUSED+1 
  #RASCS_CallbackSetByCaller = #RASCS_PAUSED+2 
  #RASCS_PasswordExpired = #RASCS_PAUSED+3 
  #RASCS_Connected = #RASCS_DONE 
  #RASCS_Disconnected = #RASCS_DONE+1 
EndEnumeration 


Structure RASCONNSTATUS
  dwSize.l
  rasconnstate.l
  dwError.l
  szDeviceType.b[#RAS_MaxDeviceType + 1]
  szDeviceName.b[#RAS_MaxDeviceName + 1]
EndStructure 


Structure RASDIALPARAMS
  dwSize.l
  szEntryName.b[#RAS_MaxEntryName + 1]
  szPhoneNumber.b[#RAS_MaxPhoneNumber + 1]
  szCallbackNumber.b[#RAS_MaxCallbackNumber + 1]
  szUserName.b[#UNLEN + 1]
  szPassword.b[#PWLEN + 1]
  szDomain.b[#DNLEN + 1]
EndStructure 

Global RDP.RASDIALPARAMS, hRasConn.l
hRasConn.l=#null
RCS.RASCONNSTATUS
RCS\dwSize = SizeOf(RCS)

Procedure DialMessage(msg.s)
  AddGadgetItem(2, 0, msg)
  While WindowEvent() : Wend
EndProcedure

Procedure dial( entryname.s, phone.s, login.s, pass.s )
  RDP\dwSize = 1052
  PokeS(@RDP\szEntryName,entryname)
  PokeS(@RDP\szPhoneNumber,phone)
  PokeS(@RDP\szCallbackNumber ,"")
  PokeS(@RDP\szUserName, login)
  PokeS(@RDP\szPassword,pass)
  PokeS(@RDP\szDomain,"")
  
  DialMessage("Dialing " + phone)
  
  RasDial_(#null, #null, @RDP, #null, #null, @hRasConn)
EndProcedure
Procedure hangup(con.l)
  rashangup_(con)
  Delay(5000)
EndProcedure

OpenWindow(0, 341, 122, 200, 150,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
CreateGadgetList(WindowID())
ButtonGadget(0, 60, 5, 40, 20, "dial")
ButtonGadget(1, 100, 5, 50, 20, "hangup")
ListViewGadget(2, 5, 30, 190, 115)

Repeat
  Delay(1)
  EventID.l = WaitWindowEvent()
  Select EventID
    Case #PB_EventGadget
      Select EventGadgetID()
        Case 0
          dial( "freenet.de","019231770" ,"freeme" , "yesican" )
          Repeat
            While WindowEvent() : Wend
            RasGetConnectStatus_(hRasConn, @RCS)
          Until RCS\rasconnstate = #RASCS_Connected
          DialMessage("Connected successfully")
        Case 1
          hangup(hRasConn)
      EndSelect
    Case #PB_EventCloseWindow
      If EventID = #PB_EventCloseWindow
        hangup(hRasConn)
        End
      EndIf
  EndSelect
ForEver
There were some Bugs regarding RasHangUp_() and RasGetConnectStatus_(). They are expecting hRasConn and not @hRasConn

Any Ideas at how to get more Info and Messages about the DialIn Process?

Posted: Wed May 12, 2004 8:12 pm
by TerryHough
@freedimension

I made a few more changes to make this more reliable on my Win98SE system, not tested on other versions. The code you had just modified was still failing to disconnect the line on my system.

I changed some constant values and a bit of the logic and reporting code.

Code: Select all

; from PB topic http://jconserv.net/purebasic/viewtopic.php?t=7763&postdays=0&postorder=asc&start=45
; as modified by Freedimension and TerryHough - May 12, 2004


#RAS_MaxEntryName = 256 
#RAS_MaxPhoneNumber = 128 
#RAS_MaxCallbackNumber = 128 
#UNLEN = 256 
#PWLEN = 256 
#DNLEN = 15 

#RAS_MaxDeviceType = 16 
#RAS_MaxDeviceName = 128 
#RASCS_PAUSED = 4096 
#RASCS_DONE = 8192 

Enumeration 
  #RASCS_OpenPort = 0 
  #RASCS_PortOpened 
  #RASCS_ConnectDevice 
  #RASCS_DeviceConnected 
  #RASCS_AllDevicesConnected 
  #RASCS_Authenticate 
  #RASCS_AuthNotify 
  #RASCS_AuthRetry 
  #RASCS_AuthCallback 
  #RASCS_AuthChangePassword 
  #RASCS_AuthProject 
  #RASCS_AuthLinkSpeed 
  #RASCS_AuthAck 
  #RASCS_ReAuthenticate 
  #RASCS_Authenticated 
  #RASCS_PrepareForCallback 
  #RASCS_WaitForModemReset 
  #RASCS_WaitForCallback 
  #RASCS_Projected 
  #RASCS_StartAuthentication 
  #RASCS_CallbackComplete 
  #RASCS_LogonNetwork 
  #RASCS_SubEntryConnected 
  #RASCS_SubEntryDisconnected 
EndEnumeration 

  #RASCS_Interactive = #RASCS_PAUSED 
  #RASCS_RetryAuthentication = #RASCS_PAUSED+1 
  #RASCS_CallbackSetByCaller = #RASCS_PAUSED+2 
  #RASCS_PasswordExpired = #RASCS_PAUSED+3 

  #RASCS_Connected = 0 
  #RASCS_Disconnected = 1 

Global results.l

Structure RASCONNSTATUS 
  dwSize.l 
  rasconnstate.l 
  dwError.l 
  szDeviceType.b[#RAS_MaxDeviceType + 1] 
  szDeviceName.b[#RAS_MaxDeviceName + 1] 
EndStructure 

Structure RASDIALPARAMS 
  dwSize.l 
  szEntryName.b[#RAS_MaxEntryName + 1] 
  szPhoneNumber.b[#RAS_MaxPhoneNumber + 1] 
  szCallbackNumber.b[#RAS_MaxCallbackNumber + 1] 
  szUserName.b[#UNLEN + 1] 
  szPassword.b[#PWLEN + 1] 
  szDomain.b[#DNLEN + 1] 
EndStructure 

Global RDP.RASDIALPARAMS, hRasConn.l 
hRasConn.l=#null 
RCS.RASCONNSTATUS 
RCS\dwSize = SizeOf(RCS) 

Procedure DialMessage(msg.s) 
  AddGadgetItem(2, -1, msg) 
  While WindowEvent() : Wend 
EndProcedure 

Procedure dial( entryname.s, phone.s, login.s, pass.s ) 
  RDP\dwSize = 1052 
  PokeS(@RDP\szEntryName,entryname) 
  PokeS(@RDP\szPhoneNumber,phone) 
  PokeS(@RDP\szCallbackNumber ,"") 
  PokeS(@RDP\szUserName, login) 
  PokeS(@RDP\szPassword,pass) 
  PokeS(@RDP\szDomain,"") 
  DialMessage("Dialing " + phone) 
  results = RasDial_(#null, #null, @RDP, #null, #null, @hRasConn) 
EndProcedure 

Procedure hangup(con.l) 
  RasHangUp_(con) 
  DialMessage("Hanging up...")
  Delay(5000)
  DialMessage("Disconnected successfully")
EndProcedure 

OpenWindow(0, 341, 122, 250, 150,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )") 
CreateGadgetList(WindowID()) 
ButtonGadget(0, 60, 5, 40, 20, "Dial") 
ButtonGadget(1, 140, 5, 50, 20, "Hangup") 
ListViewGadget(2, 5, 30, 240, 115) 

Repeat 
  Delay(1) 
  EventID.l = WaitWindowEvent() 
  Select EventID 

    Case #PB_EventGadget 
      Select EventGadgetID() 
        Case 0 
          dial( "YourRASentry","123-4567" ,"YourID" , "YourPassword" ) 
          If results = 0
            Repeat
              RasGetConnectStatus_(hRasConn, @RCS) 
            Until RCS\rasconnstate = #RASCS_Connected 
            DialMessage("Connected successfully - Return code "+Str(RCS\rasconnstate))
          Else 
            DialMessage("Connection unsuccessful - Return code " + Str(results))
          EndIf 
        Case 1 
          hangup(hRasConn)
          RCS\rasconnstate = #RASCS_Disconnected
      EndSelect 

  EndSelect 
Until EventID = #PB_EventCloseWindow

RasGetConnectStatus_(hRasConn, @RCS) 
If RCS\rasconnstate = #RASCS_Connected
  hangup(hRasConn)
EndIf 
DialMessage("Session terminated")
Delay(5000) 
End
I would think you could create a callback that interpreted the condition of RASCONNSTATE and reported it. That should give you a more explicit idea of the RAS process. Sorry, I don't have any code to share.

Terry

Great !

Posted: Wed May 12, 2004 10:44 pm
by DominiqueB
Thank's for that code.
One question:
I see the need for a phonebook entry:
"dial( "YourRASentry", "123-4567" , "YourID" , "YourPassword" )"

If none is created is it possible to programmaticaly create one given phone number, password, . . .

Thank's[/code]

Re: Great !

Posted: Thu May 13, 2004 8:09 pm
by TerryHough
DominiqueB wrote:is it possible to programmaticaly create one given phone number, password, . . .
Should be, but I haven't had any luck at it. This is handled differently on WinNT and I have seen a couple of examples for that (not on this forum).

I am running Win98SE and have had no luck reading or modifying DUN entries. Probably because I really don't know what I am doing. :(

Terry

Posted: Thu Mar 10, 2005 12:23 am
by PureUser
Just wanted to know, why when I press second time button DIAL an error appears (668). Who has such a thing? Ive tested on 2 computers - the same thing. all running win2k
HELP!

Re: RAS connect and so on

Posted: Thu Oct 30, 2014 10:04 am
by Liqu
hi, how to use Pre Shared key?

would you please help me add the feature?
RASCREDENTIALS
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

thanks