Read the program from the registry

xiaoxiao2021-03-06  82

From the registry read program version of the Torne Sea (SunHai) Development Tool: Microsoft Visual Studio .NET 2003 Operating System: Windows XP is likely to use automatic dialing when writing a network program. For example, the mail group sending software software is replaced with the native IP address with automatic disconnection and dialing. To achieve automatic dial, divided into two steps: read the native dial-up link name from the registry; automatic dialing. Call the API function Read the native dial-up link name from the registry before calling the API function to read the native dial 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 String, ByRef phkResult As Integer) As IntegerPrivate Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Integer) As IntegerPrivate Declare Function RegEnumKey Lib "advapi32.dll" Alias ​​"RegEnumKeyA" (ByVal hKey As Integer, ByVal dwIndex As Integer, 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, "RemoteAccess / Profile", hKey) = ERROR_SUCCESS Then While RegEnumKey (hKey, i, astr, 256 = Error_suCcess MsgBox (astr) 'Link Name I = 1 End while regclosekey (HKEY) End If, use the RegistryKey class read the link name RegistryKey class represents the item-level node in the Windows registry. This type is a registry package. This article mainly uses: registryKey.opensubkey method: Retrieve the specified child with the specified write access. Retrieve the subkey in read-only mode. [Visual Basic] Overloads Public Function OpenSubkey (String) AS RegistryKey RegistryKey.getsubKeynames method: Retrieves an array of strings containing all child names. Public function getSubkeyNames () AS String () Using the registryKey read link name can be said to be very simple:

Dim rk As RegistryKey = _Registry.CurrentUser.OpenSubKey ( "RemoteAccess / Profile", True) 'Get the data from a specified item in the key.Dim s As String () = rk.GetSubKeyNames () For num As Integer = 0 To S.Length - 1 msgbox (s.getvalue (num)) 'This is that the link name next NEXT automatically dials the automatic dial-up reading link, the automatic dialing is very simple. Open the Control Panel, Network Connections, Connect the Properties, Options, Remove the "Prompt Name, Password, Certificate, etc. (P)". Shell ("rasphone.exe -d" & linksname, appwinstyle.hide, true, -1) launched the "Command Prompt", type the "Dial-up Network dialog", populates the "Dial-up Network dialog". If you type rasphone -h, enter, populate the "Dial-up Network Command Line", list the use of Rasphone, for example, rasphone -d represents the pop-up number project dialog box. RASPHONE -LX executes a command 'x' shell function description in dial-up shortcut: AppWinStyle.hide is the parameter of Shell, indicates the hidden window and passes the focus to the window. True means waiting for dialing to complete. -1 indicates that shell is returned until the program is completed. It can also be the case:

转载请注明原文地址:https://www.9cbs.com/read-105369.html

New Post(0)