RAS connect and so on

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

be carefull here, if you use these kind of directives in code, your code will only work on ONE type of os, in other words these kind of directives are intended to develop an os specific version of the code

not a wise thing to do in my opinion...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

a little trouble...when I dial, I can't move, resize, etc my window...
Is there any solution?
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

I've got it.... but got another problem... :(

Code: Select all

RasGetConnectStatus_(@HRASCONN, *RASCONNSTATUS)
How to use RasGetConnectStatus ???

typedef enum _RASCONNSTATE {
RASCS_OpenPort = 0,
.....
}

What type is it in PB??????
Any Ideas...?
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Post by Jurgen »

Code: Select all

#RAS_MaxDeviceType = 16
#RAS_MaxDeviceName = 128


#RASCS_PAUSED = 4096
#RASCS_DONE = 8192

Enumeration
#RASCS_OpenPort = 0
#RASCS_PortOpened = 1
#RASCS_ConnectDevice = 2
#RASCS_DeviceConnected = 3
#RASCS_AllDevicesConnected = 4
#RASCS_Authenticate = 5
#RASCS_AuthNotify = 6
#RASCS_AuthRetry = 7
#RASCS_AuthCallback = 8
#RASCS_AuthChangePassword = 9
#RASCS_AuthProject = 10
#RASCS_AuthLinkSpeed = 11
#RASCS_AuthAck = 12
#RASCS_ReAuthenticate = 13
#RASCS_Authenticated = 14
#RASCS_PrepareForCallback = 15
#RASCS_WaitForModemReset = 16
#RASCS_WaitForCallback = 17
#RASCS_Projected = 18
#RASCS_StartAuthentication = 19
#RASCS_CallbackComplete = 20
#RASCS_LogonNetwork = 21
#RASCS_SubEntryConnected = 22
#RASCS_SubEntryDisconnected = 23
#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


RCS.RASCONNSTATUS

RCS\dwSize = SizeOf(RCS)

RasGetConnectStatus_(@hRasConn, @RCS)
For a list of constants and structures i always use the windows.inc file of masm32.
http://www.movsd.com/masmdl.htm
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

G R E A T thx aka 10x ;)
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

hm...tried to compile, PB gives an error on "Enumeration "....
??
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

heh..lamerz must die! Just updated PB... ;)
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

don't trouble trouble...
Yet another trouble, when I press DIAL button the window does not respond (resize, move etc )... + in the variable "res" there is no RasGetConnectStatus Status :(

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 = 1 
#RASCS_ConnectDevice = 2 
#RASCS_DeviceConnected = 3 
#RASCS_AllDevicesConnected = 4 
#RASCS_Authenticate = 5 
#RASCS_AuthNotify = 6 
#RASCS_AuthRetry = 7 
#RASCS_AuthCallback = 8 
#RASCS_AuthChangePassword = 9 
#RASCS_AuthProject = 10 
#RASCS_AuthLinkSpeed = 11 
#RASCS_AuthAck = 12 
#RASCS_ReAuthenticate = 13 
#RASCS_Authenticated = 14 
#RASCS_PrepareForCallback = 15 
#RASCS_WaitForModemReset = 16 
#RASCS_WaitForCallback = 17 
#RASCS_Projected = 18 
#RASCS_StartAuthentication = 19 
#RASCS_CallbackComplete = 20 
#RASCS_LogonNetwork = 21 
#RASCS_SubEntryConnected = 22 
#RASCS_SubEntryDisconnected = 23 
#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=NULL
RCS.RASCONNSTATUS 
RCS\dwSize = SizeOf(RCS) 

Procedure dial( entryname$, phone$, login$, pass$ )
RDP\dwSize = 1052  ;SizeOf(RASDIALPARAMS)
PokeS(@RDP\szEntryName,entryname$)
PokeS(@RDP\szPhoneNumber,"p" + phone$)
PokeS(@RDP\szCallbackNumber ,"")
PokeS(@RDP\szUserName, login$)
PokeS(@RDP\szPassword,pass$)
PokeS(@RDP\szDomain,"")
RasDial_(null, null, @RDP, null, null, @hRasConn)
EndProcedure 

OpenWindow(0, 341, 122, 196, 77,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
CreateGadgetList(WindowID())
ButtonGadget(0, 100, 20, 70, 30, "dial")

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

Select EventID
     Case #PB_EventGadget
              Select EventGadgetID()
              Case 0
              OpenWindow(1, 100, 122, 196, 77,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "2nd window", 0)
              dial( "connection","911" ,"test" , "test" )
              res = 0
              While res=0
              res = RasGetConnectStatus_(@hRasConn, @RCS)
              Wend
              Debug res
              Delay(600)
              rashangup_(@hRasConn)
              EndSelect
              EndSelect
Until EventID = #PB_EventCloseWindow
if eventID = #PB_EventCloseWindow
rashangup_(@hRasConn)
endif
Any Ideas???
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Post by Jurgen »

The window doesnt respond because your program is in a loop, where it cant get out of. Because res is always 0. I think :)

Code: Select all

While res=0 
     res = RasGetConnectStatus_(@hRasConn, @RCS) 
Wend 
If res = 0, this means that the function succeeds :
Return Values

If the function succeeds, the return value is zero.
If the function fails, the return value is a nonzero error value listed in the RAS header file or one of ERROR_BUFFER_TOO_SMALL or ERROR_NOT_ENOUGH_MEMORY.
The connection status, is filled in your structure RCS.


good luck
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

thx, but that doesn't really changes something...the same problem with "frozen" window...
Jurgen
User
User
Posts: 37
Joined: Mon Sep 08, 2003 11:53 pm

Post by Jurgen »

I don't know why the window is frozen.
Do you hear the modem dialing the number ?
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

yes , the modem dials good ;) but the window stays frozen...try to compile the source ... you will see...
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

so can anyone help me????
or no valanteers ?? ;)
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

PureUser wrote:so can anyone help me????
@PureUser

I am not sure I am qualified to help. But since I am very interested in
a RAS dialer I took a look at the code posted and tested with it a bit.

Jurgen is correct in that your program is in a loop because res = 0.
However, the reason it is 0 is not because the API call is being
completed successfully.

At least here on my machine (Win98SE), the first attempt to run the
program dials and then ends, but doesn't clear the screen. Subsequent
attempts to run the program bypass the dialing and the results of the

Code: Select all

res = RasGetConnectStatus_(hRasConn, @RCS)
always returns as 0. This continues until a hard boot is done.

The reason for this is that you issue a RasHangUp_(@hRasConn)
and immediately end the program. The API documentation advises
against that as it leaves the port in limbo. This is what causes the
failure to dial and the incorrect resuls from the ConnectStatus on
subsequent runs.

You can Delay(3000) after the RasHangUp_(@hRasConn) and perhaps
solve that, although I have found that it isn't always enough. The best
way is to query the results of the
RasGetConnectStatus_(hRasConn, @RCS)
until it returns an Invalid Connection result indicating that the opened
connection has been disconnected and removed before exiting.

Unfortunately, I wasn't successful in doing that. My guess is that the
Structure RASCONNSTATUS is not defined correctly. What little
documentation I have access to indicates it should be 160 bytes total.

Therein lies much of my problems with RAS. I don't have complete
documentation of the RASHEADERS, etc. to work with. Perhaps you
do.

Hopefully this will help. If you get it working, please post your code. I
will do the same.

Regards,
Terry
PureUser
User
User
Posts: 31
Joined: Sun Oct 05, 2003 11:18 pm

Post by PureUser »

Im workin` at RAS... findin` a way to clear my mind (not format C: ) ;) I found some interestin` info:
Its an API func, as I was said :

Code: Select all

DWORD WINAPI RasDialCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError)
{
	if(hrasconn==hRasConn)
	{
		char msg[255];
		if(dwError!=0)
		{
			char err[255];
			RasGetErrorString(dwError,err,255);
			mdlg->ConOut("Error %d: %s",dwError,err);
			if(dwError==691 || dwError==734)
			{
				if(dwError==734)
					mdlg->ExceptDomain(mdlg->curacc->l);
				RasSafeHangUp(hRasConn);
				hRasConn=NULL;
				mdlg->DialNext();
			}
			else if(dwError==676)
			{
				RasSafeHangUp(hRasConn);
				hRasConn=NULL;
				mdlg->DialNext(false);
			}
			return 1;
		}
		RasConnStateGetStrEvent(rascs,msg);
		mdlg->ConOut(msg);
	}

	return 1;
}

Its a part of source in C++... This a kind of some help ;)
Post Reply