在Delphi中使用RAS实现对系统拨号的控制
在Delphi中使用RAS实现对系统拨号的控制
在企业应用中有时候希望能在程序中实现对拨号网络的控制,以实现自动拨号、自动断开网络。在尝试了多种方式之后,认为RAS是一种比较稳定的方式。在google了网上一些资料后,现整理如下:
一、首先需要有个针对RAS的头文件定义,Ras.pas代码如下
{* Copyright (c) 1992-1995, Microsoft Corporation, all rights reserved
**
** ras.h
** Remote Access external API
** Public header for external API clients
*}
{ Delphi conversion by Davide Moretti <dmoretti@iper.net> }
{ Note: All functions and structures defaults to Ansi. If you want to use
Unicode structs and funcs, use the names ending with 'W' }
unit Ras;
interface
uses Windows, Messages;
const
{ These are from lmcons.h }
DNLEN = 15; // Maximum domain name length
UNLEN = 256; // Maximum user name length
PWLEN = 256; // Maximum password length
NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
RAS_MaxDeviceType = 16;
RAS_MaxPhoneNumber = 128;
RAS_MaxIpAddress = 15;
RAS_MaxIpxAddress = 21;
{ Note: you must define WINVER31 before compiling this unit to get the sizes
for the 3.x version of RAS. The default is for Windows 95 and NT 4.0 }
{$IFDEF WINVER31}
{Version 3.x sizes }
RAS_MaxEntryName = 20;
RAS_MaxDeviceName = 32;
RAS_MaxCallbackNumber = 48;
{$ELSE}
{Version 4.x sizes }
RAS_MaxEntryName = 256;
RAS_MaxDeviceName = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
{$ENDIF}
type
LPHRasConn = ^THRasConn;
THRasConn = Longint;
{* Identifies an active RAS connection. (See RasEnumConnections)
*}
LPRasConnW = ^TRasConnW;
TRasConnW = record
dwSize: Longint;
hrasconn: THRasConn;
szEntryName: Array[0..RAS_MaxEntryName] of WideChar;
{$IFNDEF WINVER31}
szDeviceType: Array[0..RAS_MaxDeviceType] of WideChar;
szDeviceName: Array[0..RAS_MaxDeviceName] of WideChar;
{$ENDIF}
end;
LPRasConnA = ^TRasConnA;
TRasConnA = record
dwSize: Longint;
相关文档:
1. 抽象工厂的产品
{《HeadFirst设计模式》工厂模式之抽象工厂 }
{ 抽象工厂的产品 }
{ 编译工具:Delphi7.0 }
{ E-Mail :xshlife@163.com }
unit uPizzaIngredient;
interface
type
TDough = class(TObject)
end;
TThinCrustDough ......
继承是为了表现类与类之间“是一种”关系,是多态存在的基础,继承是面象对象必不可少的基础,只支持封装而不支持继承的语言只能称为“基于对象”(Object-Based)面非面向对象“Object-Oriented”;
Object Pascal只支持单继承,也就是一个派生类只能有一个基类
但可以实现多个接口 ......
构建 Windows SOAP 服务器应用程序
首先在 Windows 上构建服务器,然后在 Linux 上构建客户机。(如果需要,可以使用其它方法 — 或者将它们全部构建在 Windows 或 Linux 上。)对于 Windows SOAP 服务器,启动 Delphi 7 Enterprise,执行 File -> New -> Other,转至对象资源库(Object Repository)的 ......
由于项目需要,开始学习DELPHI,并自己编写代码来测试用VC写的DLL,觉得自己又多掌握了一些,不对的地方希望指正,我会好好学习
1、响应键盘事件:
因为KeyPreview默认是 False;我们这里需要响应键盘事件的话,需要将其修改为True;
所以KeyPreview:=True; 这对一些快捷键会有用。
在FormCreate这个函数里修改KeyPrevie ......