读取系统地址簿
function RasEnumEntries(resered: PAnsiChar; lpszPhoneBook: PAnsiChar;
entrynamesArray: LPRasEntryName; var lpcb: LongInt;
var lpcEntries: LongInt): LongInt; stdcall;
如 RasEnumEntries(nil, nil, @Entries[1], Size, EntriesNum)
前两个参数Win98不用,
Entries:Array[1..100] of TRasEntryName 指向存放连接信息的缓冲区
Entries[1].dwSize := SizeOf(TRasEntryName)
Size := SizeOf(TRasEntryName) * 100; 缓冲区大小
EntriesNum 返回实际读取连接数
检查连接(Win32API,没有转化为DELPHI)
DWORD RasGetConnectStatus(HRASCONN hrasconn,LPRASCONNSTATUS lprasconnstatus);
hrasconn为RasDial中的hRas连接句柄
lprasconnstatus为结构指针
typedef struct _RASCONNSTATUS {
DWORD dwSize;
RASCONNSTATE rasconnstate;
DWORD dwError;
TCHAR szDeviceType[RAS_MaxDeviceType + 1];
TCHAR szDeviceName[RAS_MaxDeviceName + 1];
} RASCONNSTATUS;
其中rasconnstate为RASCS_Connected或RASCS_Disconnected
断开拨号用
RasHangUp(hRas)
由于不能马上完成,用RasGetConnectStatus(hRas, Status)=ERROR_INVALID_HANDLE
Status为结构TRasConnStatus
Status.dwSize = SizeOf(TRasConnStatus)
建立和断开对话框网络连接
建立
WNetConnectionDialog(Handle, RESOURCETYPE_DISK);
断开
WNetDisconnectDialog(Handle, RESOURCETYPE_DISK);
建立和断开网络连接
建立
function WNetAddConnection2(var lpNetResource: TNETRESOURCE;
lpPassword: LPCSTR;
lpUserName: LPCSTR;
dwFlags: DWORD); DWORD; stdcall;
断开
function WNetCancelConnection2(lpName: LPCSTR; dwFlag: DWORD;
fForce: Boolean): DWORD; stdcall;