📄 jvqras32.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvRas32.PAS, released on 2001-02-28.
The Initial Developer of the Original Code is S閎astien Buysse [sbuysse att buypin dott com]
Portions created by S閎astien Buysse are Copyright (C) 2001 S閎astien Buysse.
All Rights Reserved.
Contributor(s): Michael Beck [mbeck att bigfoot dott com].
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQRas32.pas,v 1.14 2004/09/07 23:11:34 asnepvangers Exp $
unit JvQRas32;
{$I jvcl.inc}
{$I windowsonly.inc}
interface
uses
SysUtils, Classes, QControls, QForms,
Qt, QRas32,
JvQComponent,
Windows, Messages,
// Messages must be after QControls
JvQTypes;
type
TJvRas32 = class(TJvComponent)
private
FPhoneBookPath: TFileName;
FPassword: string;
FDeviceName: string;
FUsername: string;
FEntry: string;
FDeviceType: string;
FPhoneNumber: string;
FCallBackNumber: string;
FDomain: string;
FConnection: DWORD;
FHandle: THandle;
FPHandle: THandle;
RASEvent: Word;
FEntryIndex: Integer;
FDummyConnected: Boolean;
FPhoneBook: TStringList;
FOnAuthProject: TNotifyEvent;
FOnAuthChangePassword: TNotifyEvent;
FOnAuthLinkSpeed: TNotifyEvent;
FOnDisconnected: TNotifyEvent;
FOnAuthNotify: TNotifyEvent;
FOnDeviceConnected: TNotifyEvent;
FOnReAuthenticate: TNotifyEvent;
FOnAuthAck: TNotifyEvent;
FOnConnectDevice: TNotifyEvent;
FOnAuthRetry: TNotifyEvent;
FOnAuthenticate: TNotifyEvent;
FOnWaitForModemReset: TNotifyEvent;
FOnOpenPort: TNotifyEvent;
FOnAuthCallback: TNotifyEvent;
FOnRetryAuthentication: TNotifyEvent;
FOnPortOpened: TNotifyEvent;
FOnWaitForCallBack: TNotifyEvent;
FOnPrepareForCallback: TNotifyEvent;
FOnPasswordExpired: TNotifyEvent;
FOnInteractive: TNotifyEvent;
FOnConnected: TNotifyEvent;
FOnAuthenticated: TNotifyEvent;
FOnAllDevicesConnected: TNotifyEvent;
FDll: THandle;
FRasDial: TRasDial;
FRasEnumConnections: TRasEnumConnections;
FRasEnumEntries: TRasEnumEntries;
FRasGetConnectStatus: TRasGetConnectStatus;
FRasGetErrorstring: TRasGetErrorstring;
FRasHangUp: TRasHangUp;
FRasGetEntryDialParams: TRasGetEntryDialParams;
FRasValidateEntryName: TRasValidateEntryName;
FRasCreatePhonebookEntry: TRasCreatePhonebookEntry;
FRasEditPhonebookEntry: TRasEditPhonebookEntry;
FKeepConnected: Boolean;
// function GetPhoneBook: TStringList;
procedure WndProc(var Msg: TMessage);
procedure SetEntryIndex(const Value: Integer);
function GetConnected: Boolean;
function GetPhoneBook: TStrings;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure RefreshPhoneBook;
function Dial(Index: Integer): Boolean;
function HangUp: Boolean;
function CreateNewConnection: Boolean;
function EditConnection(Index: Integer): Boolean;
function GetActiveConnection: string;
property CallBackNumber: string read FCallBackNumber write FCallBackNumber;
property DeviceType: string read FDeviceType;
property DeviceName: string read FDeviceName;
property PhoneNumber: string read FPhoneNumber write FPhoneNumber;
property Domain: string read FDomain write FDomain;
property PhoneBook: TStrings read GetPhoneBook;
published
property KeepConnected: Boolean read FKeepConnected write FKeepConnected default False;
// property PhoneBook: TStringList read GetPhoneBook;
property EntryIndex: Integer read FEntryIndex write SetEntryIndex default -1;
property PhoneBookPath: TFileName read FPhoneBookPath write FPhoneBookPath;
property Entry: string read FEntry write FEntry;
property Username: string read FUsername write FUsername;
property Password: string read FPassword write FPassword;
property Connected: Boolean read GetConnected write FDummyConnected stored False;
property OnOpenPort: TNotifyEvent read FOnOpenPort write FOnOpenPort;
property OnPortOpened: TNotifyEvent read FOnPortOpened write FOnPortOpened;
property OnConnectDevice: TNotifyEvent read FOnConnectDevice write FOnConnectDevice;
property OnDeviceConnected: TNotifyEvent read FOnDeviceConnected write FOnDeviceConnected;
property OnAllDevicesConnected: TNotifyEvent read FOnAllDevicesConnected write FOnAllDevicesConnected;
property OnAuthenticate: TNotifyEvent read FOnAuthenticate write FOnAuthenticate;
property OnAuthNotify: TNotifyEvent read FOnAuthNotify write FOnAuthNotify;
property OnAuthRetry: TNotifyEvent read FOnAuthRetry write FOnAuthRetry;
property OnAuthCallback: TNotifyEvent read FOnAuthCallback write FOnAuthCallback;
property OnAuthChangePassword: TNotifyEvent read FOnAuthChangePassword write FOnAuthChangePassword;
property OnAuthProject: TNotifyEvent read FOnAuthProject write FOnAuthProject;
property OnAuthLinkSpeed: TNotifyEvent read FOnAuthLinkSpeed write FOnAuthLinkSpeed;
property OnAuthAck: TNotifyEvent read FOnAuthAck write FOnAuthAck;
property OnReAuthenticate: TNotifyEvent read FOnReAuthenticate write FOnReAuthenticate;
property OnAuthenticated: TNotifyEvent read FOnAuthenticated write FOnAuthenticated;
property OnPrepareForCallback: TNotifyEvent read FOnPrepareForCallback write FOnPrepareForCallback;
property OnWaitForModemReset: TNotifyEvent read FOnWaitForModemReset write FOnWaitForModemReset;
property OnInteractive: TNotifyEvent read FOnInteractive write FOnInteractive;
property OnRetryAuthentication: TNotifyEvent read FOnRetryAuthentication write FOnRetryAuthentication;
property OnPasswordExpired: TNotifyEvent read FOnPasswordExpired write FOnPasswordExpired;
property OnConnected: TNotifyEvent read FOnConnected write FOnConnected;
property OnDisconnected: TNotifyEvent read FOnDisconnected write FOnDisconnected;
property OnWaitForCallBack: TNotifyEvent read FOnWaitForCallBack write FOnWaitForCallBack;
end;
// (rom) renamed
EJvRasError = class(EJVCLException);
implementation
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JvQJVCLUtils, JvQResources;
constructor TJvRas32.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FKeepConnected := False;
FPhoneBookPath := '';
FPassword := '';
FDeviceName := '';
FUsername := '';
FEntry := '';
FDeviceType := '';
FPhoneNumber := '';
FCallBackNumber := '';
FDomain := '';
FConnection := 0;
FHandle := AllocateHWndEx(WndProc);
RASEvent := RegisterWindowMessage(RASDialEvent);
if RASEvent = 0 then
RASEvent := WM_RASDialEvent;
if AOwner is TWinControl then
FPHandle := QWidget_winid((AOwner as TWinControl).Handle)
else
// (rom) is this safe?
FPHandle := GetForegroundWindow;
FEntryIndex := -1;
FDll := LoadLibrary(PChar(RsRasDllName));
if FDll <> 0 then
begin
FRasDial := GetProcAddress(FDll, 'RasDialA');
FRasEnumConnections := GetProcAddress(FDll, 'RasEnumConnectionsA');
FRasEnumEntries := GetProcAddress(FDll, 'RasEnumEntriesA');
FRasGetConnectStatus := GetProcAddress(FDll, 'RasGetConnectStatusA');
FRasGetErrorstring := GetProcAddress(FDll, 'RasGetErrorstringA');
FRasHangUp := GetProcAddress(FDll, 'RasHangUpA');
FRasGetEntryDialParams := GetProcAddress(FDll, 'RasGetEntryDialParamsA');
FRasValidateEntryName := GetProcAddress(FDll, 'RasValidateEntryNameA');
FRasCreatePhonebookEntry := GetProcAddress(FDll, 'RasCreatePhonebookEntryA');
FRasEditPhonebookEntry := GetProcAddress(FDll, 'RasEditPhonebookEntryA');
end
else
raise EJvRasError.CreateRes(@RsERasError);
end;
destructor TJvRas32.Destroy;
begin
FPhoneBook.Free;
if FDll <> 0 then
begin
try
if not KeepConnected then
HangUp;
except
end;
FreeLibrary(FDll);
end;
DeallocateHWndEx(FHandle);
inherited Destroy;
end;
function TJvRas32.GetActiveConnection: string;
var
Ret: Longint;
nCB: DWORD;
RasConn: array [0..63] of TRASCONN;
nRasConnCount: DWORD;
I: Integer;
begin
Result := '';
RasConn[0].dwSize := SizeOf(TRASCONN);
nCB := SizeOf(RasConn);
Ret := FRasEnumConnections(@RasConn, nCB, nRasConnCount);
if (Ret <> Success) or (nRasConnCount = 0) then
Exit;
if not Assigned(FPhoneBook) then
RefreshPhoneBook;
for I := 0 to FPhoneBook.Count - 1 do
if FPhoneBook[I] = RasConn[0].szEntryName then
begin
FConnection := RasConn[0].rasConn;
Result := FPhoneBook[I];
Break;
end;
end;
function TJvRas32.CreateNewConnection: Boolean;
begin
if Assigned(FRasCreatePhonebookEntry) then
Result := FRasCreatePhonebookEntry(FPHandle, nil) = 0
else
Result := False;
end;
function TJvRas32.Dial(Index: Integer): Boolean;
var
RASDialParams: TRASDialParams;
R: DWORD;
X: Integer;
begin
if FConnection <> 0 then
Result := False
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -