Dial-dialing with Modem is still the way most personal netizens choose to access the Internet. If you can start dial-up connections in our app (such as the automatic dial function in the IE browser program), it will undoubtedly be convenient for our software users (without switching applications, run dialing network), and improve our software friendship. Sexually improve software competitiveness. Under Win9X, if the dial network is installed, there will be two dial-up network management library rasapi32.dll and rasapi16.dll under the system directory system of the Windows system, we can use the functions to create, modify dial-up connections, and Dial-up net using the specified dial-up connection. First, a new dial-up connection When a dial-up connection has been established in the Win9x system, you can use the ready-made dial-up connection. If there is no dial-up connection, you need to create a new dial-up connection.
RasAPI provided in a corresponding function, which is a function named RasCreatePhonebookEntryA, the function prototype: function RasCreatePhonebookEntryA (hwnd: THandle; lpszPhonebook: pchar): DWORD; stdcall; {interface portion located} function RasCreatePhonebookEntryA; external 'Rasapi32.dll'; { Located in the Implementation section} parameter: hwnd (thandle): Create a handle of the parent window of the dial-up window, can be TFORM's handle, a NIL table; Windows Desktop (Desktop) Lpszphonebook (Pchar): Phone this name, no effect under Win9X However, it can be set to empty string function return value: 0 indicates execution success; otherwise it is an error. Here is an example of a new dial-up connection. New Connection {} procedure TForm1.Button1Click (Sender: TObject); var dwResult: DWORD; begin // New Connection in the current window dwResult: = RasCreatePhonebookEntryA (handle, ''); if dwResult = 0 then memo1.lines. Add (') Else Memo1.Lines.Add (' New Dial Connection Failed! ') End; Second, Modify the Properties of Specify Dial-up Connections If the user needs to modify the property such as phone number, country and area code , connection, server type, can be used to achieve RasAPI function, which function called RasEditPhonebookEntryA, the function prototype: function RasEditPhonebookEntryA (hwnd: THandle; lpszPhonebook: pchar; lpszEntryName: pchar): DWORD; stdcall; {} located interface portion function RasEditPhonebookEntryA; external 'Rasapi32.dll'; {} implementation section located parameters: hwnd (THandle): the new dial-up connection parent window handle of the window, can be expressed as NIL Windows desktop as a TForm handle (DeskTop) lpszPhonebook (pchar) : Phone this name, no effect in Win9X, can be set to empty string lpszentryName: (PCHAR): The name of the dial-up connection to the dial-up connection, such as the '163', '169' and the like return value: 0 means execution success; otherwise For a mistake. Below is an example of modifying a specified dial-up connection property. {Modify Specify Dial Connection Attribute} Procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT); var DWRESULT: DWORD; strDialName: String; begin strDialName: = '163'; // Dial-Dial connection name is set to 163 // Specify in the current window Modify the properties of the dial-up connection dWResult: =
RaseDitphoneBookenTrya (Handle, ''); if dwresult = 0 Then Memo1.Lines.Add ('Modify Dialing " StrDialName ' Success! ') Else Memo1.Lines.Add (' Modify Dialing" STRDIALNAME 'Failure!') End; Third, get the dial-up connection name available in the current system In order to make the user choose to use the dial-up connection to dial, we need to get the name of the dial-up connection established in the system. After the dial-up connection is created, Win9x writes the name and property of the dial-up connection in the registry, we can get the Dial-the-accephic name available in the current system and the default connection name set in Internet Explorer. Under the HKEY_USERS / Addresses of the registry, the name and its property settings that have been established in the dial-up network are listed, and their property settings are set, the name of each item is the name of the available dial-up connection; The purpose value is the property setting for each dial-up connection. We only need to read the names of each item to get the name of the dial-up connection available in the current system. If the default connection name is set in Internet Explorer (view = "Internet option =" Connect = "connection =" Setting = "use the following dial-up network connection), then under the hkey_usecess / .default / transaccess of the registry, there is a character. The key value of the string type, the key value name InternetProfile, which is the default connection name set by Internet Explorer.
Below is an example of obtaining the name of the dial-up connection available in the current system. {Note Uses increase in the Registry unit for operating the system registry} {Get the current name of the dial-up connection available} procedure TForm1.Button3Click (Sender: TObject); var registryTemp: TRegistry; stringsTemp: TStringlist; intIndex: integer; begin registryTemp: = TRegistry.Create; stringsTemp: = TStringlist.Create; with registryTemp do begin RootKey:. = HKEY_USERS; // set the root key HKEY_USERS // If there subkey .Default / RemoteAccess / Addresses if OpenKey ( 'Default / RemoteAccess / Addresses ', false) Then getValuenames (Stringstemp); // Read the name of each item, ie the dial-up connection name closekey; end; // The dial-up connection MEMO1.LINES.ADD (' ***** available in the current system ************************************************************************** ); For intindex: = 0 to stringstemp.count - 1 do mem1.lines.add (stringstemp.strings [infindex]); // list the default connection name IF registryTryTemp.OpenKey set in Internet Explorer ('. Default / remoteaccess ', false, then memo1.lines.a DD ('Internet Explorer is set to' registryTemp.readstring ('Internetprofile')); // Release the memory registrytemp.free; stringstemp.free; end; four, use the specified dial-up connection to the above three The purpose of the work is to dial the Internet, and now take a look at the Internet with the specified dial-up connection. The best way is to call the Win9x dial-up network service, which is an outgoing program under Win9x. In the Delphi program, you can use the following code to implement dial-up Internet access: Winexec ('Rundll32.exe RNAUI.dll, Rnadial 163', SW_SHOWNORMAL); where the last parameter "163" in the string is the name of the dial connection.