RAS connect and so on
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...
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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I've got it.... but got another problem...
How to use RasGetConnectStatus ???
typedef enum _RASCONNSTATE {
RASCS_OpenPort = 0,
.....
}
What type is it in PB??????
Any Ideas...?
Code: Select all
RasGetConnectStatus_(@HRASCONN, *RASCONNSTATUS)typedef enum _RASCONNSTATE {
RASCS_OpenPort = 0,
.....
}
What type is it in PB??????
Any Ideas...?
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)
http://www.movsd.com/masmdl.htm
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
Any Ideas???
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
The window doesnt respond because your program is in a loop, where it cant get out of. Because res is always 0. I think
If res = 0, this means that the function succeeds :
good luck
Code: Select all
While res=0
res = RasGetConnectStatus_(@hRasConn, @RCS)
Wend
The connection status, is filled in your structure RCS.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.
good luck
-
TerryHough
- Enthusiast

- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
@PureUserPureUser wrote:so can anyone help me????
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)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
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 :
Its a part of source in C++... This a kind of some help 
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;
}

