Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RASDIAL: Declare DLL caused an exception
Message
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00668507
Message ID:
00671264
Views:
17
Here is the code I have adapted from Dr. Dobbs:
I have not adapted all of the variables to VFP naming conventions. I just wanted a quick and dirty program to see if I could make it work. (If that is a problem I'll rewrite it and post it again )

***
SET PROCEDURE TO ras.prg

** RasDial Dials the connection **
DECLARE INTEGER RasDial IN RASAPI32.DLL ;
INTEGER @lRasDialExt, ;
INTEGER @lPhoneBk, ;
STRING @sRasDPar, ;
INTEGER lNotifyType, ;
INTEGER lNotify, ;
INTEGER @hRasConn

** RasGetErrorString Returns any errors from connection **
DECLARE INTEGER RasGetErrorString IN RASAPI32.DLL ;
INTEGER lErrVal, ;
STRING @sErrStr, ;
INTEGER lBufSize

** RasHangUp Function to hang up the phone **
DECLARE INTEGER RasHangUp IN RASAPI32.DLL ;
INTEGER hRasConn

DECLARE INTEGER WNetAddConnection IN WIN32API ;
STRING @sRemoteName, ;
STRING @sPassWd, ;
STRING @sLocalName

** WNetAddConnection Maps Hard Drive letter to a remote drive **
DECLARE WNetCancelConnection IN WIN32API ;
STRING @sName, ;
INTEGER lForce

*** Settings ***
login_name = 'testuser' && User is valid on test server
login_passwd = 'mypasswd'

Dialer_Name = "TestRas" && Case Sensitive (Name of Ras Dialer on test client PC)
phone_num = '550' && Extension for local "in-house" Test Server

source_dir = ''
dest_dir = ''
filename = "config.sys" && File transferred after connection is established

Volume_name = "\\NTserver236\Div3236\"
Drive_password = ''

msg_title = "RAS Transfer System"

*** Setting Up Necessary Variables And Command To WinAPI Dialer ***
Connection_Handle = 0 && Handle That RASAPI32.DLL gives back

&& We will use this to hang up the phone.
Double_word_size = CHR(28)+CHR(4)+CHR(0)+CHR(0) && Value of 1052 as a string
Connection_name = PADR(Dialer_Name+CHR(0), 257)
Connection_number = PADR(phone_num+CHR(0),257)
Callback_Number = PADR(''+CHR(0),129)
User_name = PADR(login_name+CHR(0),257)
Connection_Password = PADR(login_passwd+CHR(0),257)
Domain_name = PADR(''+CHR(0),17)


String_to_pass = Double_word_size + ;
Connection_Name + ;
Connection_Number + ;
Callback_Number+ ;
User_Name + ;
Connection_Password + ;
Domain_name

String_to_pass = PADR(string_to_pass, LEN(String_to_pass)+ (4 - LEN(String_to_pass) % 4))

STORE 0 TO zero_val
sRasDPar = string_to_pass

*** Dialing Connection ***
Return_Value = RasDial(zero_val,zero_val,@sRasDPar,zero_val,zero_val,@Connection_Handle)

** Evaluate Return Code **
IF RETURN_Value # 0
Message_Buffer = SPACE(256) && Placeholder for error messages
IF !EMPTY(RasGetErrorString(Return_value, @Message_Buffer, LEN(Message_Buffer)))
=MESSAGEBOX("Unknown Error", 16, msg_title)
ELSE
=MESSAGEBOX(ALLTRIM(message_buffer))
ENDIF
RETURN
ENDIF

I receive my exception error as soon as RASDIAL is called.

Thanks for the reply
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform