Solved

Please help me call DUN using RasApi32.dll functions?

Posted on 1998-07-16
4
695 Views
Last Modified: 2008-02-01
I need help calling RasApi32.dll functions...

I've found out these three declares but don't know how to use them, what constants to use or how I get those constants...

1) Dial:

Public Declare Function RasDial Lib "RasApi32.DLL" Alias "RasDialA" (lpRasDialExtensions As Any, ByVal lpszPhonebook As String, lprasdialparams As Any, ByVal dwNotifierType As Long, lpvNotifier As Long, lphRasConn As Long) As Long

2) Hangup

Public Declare Function RasHangUp Lib "RasApi32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long

3) Status

Public Declare Function RasGetConnectStatus Lib "RasApi32.DLL" Alias "RasGetConnectStatusA" (ByVal hRasConn As Long, lpRASCONNSTATUS As Any) As Long


Please!!!!! someone, look over these three declares and give me
a source-example I could use in my app.

If you'll do that, then "your an source-expert!"
you can sitate me on that one... :)

Thanks / Bobban
0
Comment
Question by:bobban
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 90 total points
ID: 1465984
Here is the ref., I never used so, I can't give you any sc
 
The RasDial function establishes a Remote Access Service (RAS) connection between a RAS client and a RAS server. The connection data includes callback and user authentication information.
DWORD RasDial(
 

    LPRASDIALEXTENSIONS lpRasDialExtensions,      // pointer to function extensions data
    LPTSTR lpszPhonebook,      // pointer to full path and filename of phonebook file
    LPRASDIALPARAMS lpRasDialParams,      // pointer to calling parameters data
    DWORD dwNotifierType,      // specifies type of RasDial event handler
    LPVOID lpvNotifier,      // specifies a handler for RasDial events
    LPHRASCONN lphRasConn       // pointer to variable to receive connection handle
   );      
Parameters
lpRasDialExtensions
Windows NT
Points to a RASDIALEXTENSIONS structure that specifies a set of RasDial extended features to enable. If you do not need to enable any of the extensions, set this parameter to NULL.
Windows 95
This parameter is ignored. On Windows 95, RasDial always uses the default behaviors for the RASDIALEXTENSIONS options.
lpszPhonebook
Windows NT
Points to a string that specifies the full path and filename of the phonebook file. This parameter can be NULL, and typically is; in that case, RasDial uses the default phonebook file RASPHONE.PBK.
Windows 95
This parameter is ignored. Dial-up networking stores phonebook entries in the registry rather than in a phonebook file.
lpRasDialParams
Points to a RASDIALPARAMS structure that specifies calling parameters for the RAS connection.
The caller must set the RASDIALPARAMS structure's dwSize member to the sizeof(RASDIALPARAMS) to identify the version of the structure being passed.
dwNotifierType
Specifies the nature of the lpvNotifier parameter. If lpvNotifier is NULL, dwNotifierType is ignored. If lpvNotifier is not NULL, set dwNotifierType to one of the following values:
 
Value      Meaning

0xFFFFFFFF      The lpvNotifier parameter is a handle to a window to receive progress notification messages. In a progress notification message, wParam is the equivalent of the rasconnstate parameter of RasDialFunc and RasDialFunc1, and lParam is the equivalent of the dwError parameter of RasDialFunc and RasDialFunc1. The progress notification message uses a system registered message code. You can obtain the value of this message code as follows: {UINT unMsg =   RegisterWindowMessageA( RASDIALEVENT ); if (unMsg == 0)       unMsg = WM_RASDIALEVENT;    }
0      The lpvNotifier parameter points to a RasDialFunc callback function.
1      The lpvNotifier parameter points to a RasDialFunc1 callback function.
lpvNotifier
Specifies a window handle or a RasDialFunc or RasDialFunc1 callback function to receive RasDial event notifications. The dwNotifierType parameter specifies the nature of lpvNotifier. Please refer to its description preceding for further detail.
If this parameter is not NULL, RasDial sends the window a message, or calls the callback function, for each RasDial event. Additionally, the RasDial call operates asynchronously: RasDial returns immediately, before the connection is established, and communicates its progress via the window or callback function.
If lpvNotifier is NULL, the RasDial call operates synchronously: RasDial does not return until the connection attempt has completed successfully or failed.
If lpvNotifier is not NULL, notifications to the window or callback function can occur at any time after the initial call to RasDial. Notifications end when one of the following events occurs:
·      The connection is established. In other words, the RAS connection state is RASCS_Connected.
·      The connection fails. In other words, dwError is nonzero.
·      RasHangUp is called on the connection.
 
The callback notifications are made in the context of a thread captured during the initial call to RasDial.
lphRasConn
Points to a variable of type HRASCONN. You must set the HRASCONN variable to NULL before calling RasDial. If RasDial succeeds, it stores a handle to the RAS connection into *lphRasConn.
Return Values
If the function succeeds, the immediate return value is zero. In addition, the function stores a handle to the RAS connection into the variable pointed to by lphRasConn.
If the function fails, the immediate return value is a nonzero error value, either from the set listed in the RAS header file or ERROR_NOT_ENOUGH_MEMORY.
Remarks
Errors that occur after the immediate return can be detected by RasGetConnectStatus. Data is available until an application calls RasHangUp to hang up the connection.
An application must eventually call RasHangUp whenever a non-NULL connection handle is stored into *lphRasConn. This applies even if RasDial returns a nonzero (error) value.
An application can safely call RasHangUp from a RasDial notifier callback function. If this is done, however, the hangup does not occur until the routine returns.
Windows NT
If the structure pointed to by lpRasDialExtensions enables RDEOPT_PausedStates, the RasDial function pauses whenever it enters a state in which the RASCS_PAUSED bit is set to one. To restart RasDial from such a paused state, call RasDial again, passing the connection handle returned from the original RasDial call in *lphRasConn. The same notifier used in the original RasDial call must be used when restarting from a paused state.
To specify that RasDial should enter a RASCS_CallbackSetByCaller state, set lpRasDialParams->szCallbackNumber to "*" on the initial call to RasDial. When your notification handler is called with this state, you can set the the callback number to a number supplied by the user.
Windows 95
Windows 95 does not support the RASCS_CallbackSetByCaller state or any of the other paused states.
See Also
RasDialFunc, RasDialFunc1, RasGetConnectStatus, RasHangUp, RASDIALEXTENSIONS, RASDIALPARAMS, WM_RASDIALEVENT

 
 
The RASDIALEXTENSIONS structure contains information about extended features of the RasDial function. You can enable one or more of these extensions by passing a pointer to a RASDIALEXTENSIONS structure when you call RasDial. If you do not pass a pointer to a RASDIALEXTENSIONS structure to RasDial, RasDial uses the default settings that are noted following.
 
typedef  struct  _RASDIALEXTENSIONS {
    DWORD    dwSize;
    DWORD    dwfOptions;
    HWND    hwndParent;
    DWORD    reserved;
} RASDIALEXTENSIONS;
 
 
Members
dwSize
Specifies the size of this structure, in bytes. Set this member to sizeof(RASDIALEXTENSIONS). This indicates the version of the structure.
dwfOptions
A set of bit flags that specify RasDial extensions. The following bit flags are defined; you must set all undefined bits to zero:
 
Value      Description

RDEOPT_UsePrefixSuffix      If this bit flag is one, RasDial uses the prefix and suffix that is in the RAS phonebook.If this bit flag is zero, RasDial ignores the prefix and suffix that is in the RAS phonebook.If no phonebook entry name is specified in the call to RasDial, the actual value of this bit flag is ignored, and it is assumed to be zero.
RDEOPT_PausedStates      If this bit flag is one, RasDial accepts paused states. Examples of paused states are terminal mode, retry logon, change password, and set callback number.If this bit flag is zero, RasDial reports a fatal error if it enters a paused state.
RDEOPT_IgnoreModemSpeaker      If this bit flag is one, RasDial ignores the modem speaker setting that is in the RAS phonebook, and uses the setting specified by the RDEOPT_SetModemSpeaker bit flag.If this bit flag is zero, RasDial uses the modem speaker setting that is in the RAS phonebook, and ignores the setting specified by the RDEOPT_SetModemSpeaker bit flag.If no phonebook entry name is specified in the call to RasDial, the choice is between using a default setting or the setting specified by the RDEOPT_SetModemSpeaker bit flag. The default setting is used if RDEOPT_IgnoreModemSpeaker is zero. The setting specified by RDEOPT_SetModemSpeaker is used if RDEOPT_IgnoreModemSpeaker is one.
RDEOPT_SetModemSpeaker      If this bit flag is one, and RDEOPT_IgnoreModemSpeaker is one, RasDial sets the modem speaker on. If this bit flag is zero, and RDEOPT_IgnoreModemSpeaker is one, RasDial sets the modem speaker off.If RDEOPT_IgnoreModemSpeaker is zero, RasDial ignores the value of RDEOPT_SetModemSpeaker, and sets the modem speaker based on the RAS phonebook setting or the default setting.
RDEOPT_IgnoreSoftwareCompression      If this bit flag is one, RasDial ignores the software compression setting that is in the RAS phonebook, and uses the setting specified by the RDEOPT_SetSoftwareCompression bit flag.If this bit flag is zero, RasDial uses the software compression setting that is in the RAS phonebook, and ignores the setting specified by the RDEOPT_SetSoftwareCompression bit flag.If no phonebook entry name is specified in the call to RasDial, the choice is between using a default setting or the setting specified by the RDEOPT_SetSoftwareCompression bit flag. The default setting is used if RDEOPT_IgnoreSoftwareCompression is zero. The setting specified by RDEOPT_SetSoftwareCompression is used if RDEOPT_IgnoreSoftwareCompression is one.
RDEOPT_SetSoftwareCompression      If this bit flag is one, and RDEOPT_IgnoreSoftwareCompression is one, RasDial uses software compression. If this bit flag is zero, and RDEOPT_IgnoreSoftwareCompression is one, RasDial does not use software compression.If RDEOPT_IgnoreSoftwareCompression is zero, RasDial ignores the value of RDEOPT_SetSoftwareCompression, and sets the software compression state based on the RAS phonebook setting or the default setting.
The default value for each of these bit flags is zero.
hwndParent
Handle to a parent window that a security DLL can use for dialog box creation and centering.
Note that this is not the window that receives RasDial progress notifications.
This member is optional; it is not required when no security DLL is defined.
The default value for this member is NULL.
reserved
This member is reserved for future use. It must be set to zero.
See Also
RasDial

 
 
The RasHangUp function terminates a remote access connection. The connection is specified with a Remote Access Service (RAS) connection handle. The function releases all RASAPI32.DLL resources associated with the handle.
DWORD RasHangUp(
 

    HRASCONN hrasconn       // handle to the RAS connection to hang up
   );      
Parameters
hrasconn
Identifies the remote access connection to terminate. This is a handle returned from a previous call to RasDial or RasEnumConnections.
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 ERROR_INVALID_HANDLE.
Remarks
The connection is terminated even if the RasDial call has not yet been completed.
After this call, the hrasconn handle can no longer be used.
An application should not call RasHangUp and then immediately exit. The connection state machine needs time to properly terminate. If the system prematurely terminates the state machine, the state machine may fail to properly close a port, leaving the port in an inconsistent state. A simple way to avoid this problem is to call Sleep(3000) after returning from RasHangUp; after that pause, the application can exit. A more responsive way to avoid the problem is, after returning from RasHangUp, to call RasGetConnectStatus(hrasconn) and Sleep(0) in a loop until RasGetConnectStatus returns ERROR_INVALID_HANDLE.
See Also
RASCONN, RasDial, RasEnumConnections, RasGetConnectStatus, Sleep

 
 
The RasGetConnectStatus function retrieves information on the current status of the specified remote access connection. An application can use this call to determine when an asynchronous RasDial call has completed.
DWORD RasGetConnectStatus(
 

    HRASCONN hrasconn,      // handle to RAS connection of interest
    LPRASCONNSTATUS lprasconnstatus      // buffer to receive status data
   );      
Parameters
hrasconn
Identifies the remote access connection for which to retrieve the status. This handle must have been obtained from RasDial or RasEnumConnections.
lprasconnstatus
Points to a RASCONNSTATUS structure that the function fills with status information. Before calling the function, an application must set the dwSize member of the structure to sizeof(RASCONNSTATUS) in order to identify the version of the structure being passed.
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.
See Also
RASCONNSTATUS, RasDial, RasEnumConnections

 

0
 

Author Comment

by:bobban
ID: 1465985
Excellent!, but a sc-example would be even better...
Thanks anyway...
I call for you if I got problems, Ok?

0
 

Author Comment

by:bobban
ID: 1465986
How do I use RasEnumConnections to get the remote access connection
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1465987
 
The RasEnumConnections function lists all active Remote Access Service (RAS) connections. It returns each connection's handle and phonebook entry name.
DWORD RasEnumConnections(
 

    LPRASCONN lprasconn,      // buffer to receive connections data
    LPDWORD lpcb,      // size in bytes of buffer
    LPDWORD lpcConnections      // number of connections written to buffer
   );      
Parameters
lprasconn
Points to a buffer that receives an array of RASCONN structures, one for each RAS connection. Before calling the function, an application must set the dwSize member of the first RASCONN structure in the buffer to sizeof(RASCONN) in order to identify the version of the structure being passed.
lpcb
Points to a variable that contains the size, in bytes, of the buffer specified by lprasconn. On return, the function sets this variable to the number of bytes required to enumerate the RAS connections.
lpcConnections
Points to a variable that the function sets to the number of RASCONN structures written to the buffer specified by lprasconn.
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.
Remarks
If a connection was made without specifying a phonebook entry name, the information returned for that connection will give the connection phone number preceded by ".".
See Also
RASCONN, RasEnumEntries, RasGetConnectStatus

 

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now