Using the program to achieve automatic dialing

Source: Internet
Author: User
Using the program to achieve automatic dialing
     
Banhai (Sunhai)
Development tools: Microsoft Visual Studio. NET 2003
Operating system: Windows XP

AutoDial is likely to be used when writing a network program. For example, bulk mail software with automatic disconnection and dial-up to achieve the replacement of the local IP address.
To achieve automatic dialing, there are two steps:
Read the native dial-up link name from the registry;
Automatic dialing.
Invoke API function to read the native dial-up link name from the registry
Previously, I called the API function to read the native dial-up link name from the registry.
Use the following code in module:
Private Declare Function regopenkey Lib "advapi32.dll" Alias "Regopenkeya" (ByVal hkey as Integer, ByVal Lpsubkey as Str ING, ByRef phkresult As Integer) As Integer
Private Declare Function regclosekey Lib "advapi32.dll" (ByVal hkey As Integer) As Integer
Private Declare Function regenumkey Lib "advapi32.dll" Alias "Regenumkeya" (ByVal hkey as Integer, ByVal dwindex as inte GER, ByVal lpname as String, ByVal cbname As Integer) As Integer
Const HKEY_CURRENT_USER as Integer = &h80000001
Const Error_no_more_items as Short = 259
Const error_success as Short = 0
Dim Hkey as Integer
Dim I as Integer
Dim astr as String = New String ("", 256)
If RegOpenKey (HKEY_CURRENT_USER, "Remoteaccessprofile", hkey) = Error_success Then
While Regenumkey (hkey, I, ASTR, 256) = ERROR_SUCCESS
MsgBox (astr) ' Link name
i + 1
End While
RegCloseKey (HKEY)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.