> This maybe useful
> http://www.chaho.de/templates/show_article.php?LanguageID=1&ID=149&GetID=1
>
Yes, this works, hurraah! :)
For those also interested, here's the source that can be found on that Web site:
procedure MyHangUp;
const
RasApi32 = 'RasApi32.dll';
RAS_MaxEntryName = 256;
RAS_MaxDeviceType = 16;
RAS_MaxDeviceName = 128;
DeviceType : PChar = 'modem';
type
RASCONN = record
dwSize: DWORD;
hrasconn: THandle;
szEntryName: array [0..RAS_MaxEntryName] of Char;
szDeviceType: array [0..RAS_MaxDeviceType] of Char;
szDeviceName: array [0..RAS_MaxDeviceName] of Char;
end;
ArrayRASCONN = array[1..7] of RASCONN; // if You have no more than 7 connections
LPRASCONN = ^ArrayRASCONN;
TRasEnumConnections = function(lprasconn: LPRASCONN;
lpcb: LPDWORD;
lpcConnections: LPDWORD):DWORD; stdcall;
TRasHangUp = function(hrasconn: THandle):DWORD; stdcall;
var
RasEnumConnections: TRasEnumConnections;
RasHangUp : TRasHangUp;
hLib : THandle;
ARasConn: ArrayRASCONN;
Sz, Connections, Rez: DWord;
lpVersionInformation: TOSVersionInfo;
Counter: Integer;
Ver: Boolean;
begin
FillChar(lpVersionInformation, SizeOf(lpVersionInformation), 0);
lpVersionInformation.dwOSVersionInfoSize := SizeOf(lpVersionInformation);
GetVersionEx(lpVersionInformation);
Ver := lpVersionInformation.dwPlatformId >= VER_PLATFORM_WIN32_WINDOWS ;
if not Ver then // verify RAS functions enable with Windows version
begin
Exit;
end;
hLib := LoadLibrary(PChar(RasApi32));
try
@RasEnumConnections := GetProcAddress(hLib,PChar('RasEnumConnectionsA'));
@RasHangUp := GetProcAddress(hLib, PChar('RasHangUpA'));
FillChar(ARasConn, SizeOf(ARasConn), 0);
ARasConn[1].dwSize := SizeOf(RASCONN);
Sz := SizeOf(ARasConn) ;
Rez := 0;
Connections := 0;
// Get Active Connections
if Assigned(RasEnumConnections) then
Rez := RasEnumConnections(@ARasConn, @Sz, @Connections);
if Assigned(RasHangUp) and (Rez = 0) and (Connections > 0) then
for Counter := 1 to Connections do
if StrComp(DeviceType, ARasConn[Counter].szDeviceType) = 0 then
RasHangUp(ARasConn[Counter].hrasconn);
finally
FreeLibrary(hLib);
end;
end;
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi