News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

problem with RasHangUp

Started by ragdog, May 23, 2007, 06:23:09 PM

Previous topic - Next topic

ragdog

hi @all

can your help with disconnect my dsl with RasHangUp api

.data?
RasCon_Buf        DD ?
Tr_Connection       RASCONN 0FFh dup ({})
hCon               DD ?
nMemAddr            dd ?

.code
start:
call rasProc
invoke ExitProcess,eax

rasProc proc
LOCAL nSize:DWORD
LOCAL nConn:DWORD
LOCAL rasStatus:RASCONNSTATUSA

   sub   eax,eax
   mov   nSize,eax
   mov   nConn,eax
invoke RasEnumEntries,NULL,NULL,offset nMemAddr,addr nSize,addr nConn
invoke   RasEnumConnections,addr nMemAddr,addr nSize,addr nConn
    mov   ebx,offset nMemAddr
    add   ebx,eax
    assumeebx:ptr RASCONN
invoke   RasGetConnectStatus,[ebx].hrasconn,addr rasStatus
invoke RasHangUp,[ebx].hrasconn
ret
rasProc endp
end start


here is a c code of rashang up:


#include <windows.h>
#pragma hdrstop
#include <condefs.h>
#include <ras.h>
//---------------------------------------------------------------------------
#pragma argsused
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
DWORD Return ;

RASCONN * pVerbindungen = new RASCONN[1];
pVerbindungen[0].dwSize = sizeof(RASCONN);
DWORD * pGroesseSpeicher = new DWORD;
DWORD * pAnzahlVerbindungen = new DWORD;

Return = RasEnumConnections(pVerbindungen, pGroesseSpeicher,
pAnzahlVerbindungen);

RasHangUp( pVerbindungen[0].hrasconn );

delete pGroesseSpeicher;
delete pAnzahlVerbindungen;
delete pVerbindungen;

pGroesseSpeicher = 0;
pAnzahlVerbindungen = 0;
pVerbindungen = 0;

return 0;
}



greets and thanks in forward

P1

ragdog,

Seeing that I never had more than one active modem going, this has served me well.  You need to add a loop for more than one active modem.
...

l_RASCONN RASCONN 0FFh dup ({})
l_Buffer_Size dd ?
l_Conn_Count  dd ?       

...

Close_RAS:
        ;Find Active Connections.
        mov l_RASCONN.dwSize, sizeof RASCONN + 1
        mov l_Buffer_Size, sizeof l_RASCONN
        invoke RasEnumConnections, addr l_RASCONN, addr l_Buffer_Size, addr l_Conn_Count
        .if eax != 0
            jmp TheEnd       
        .endif
        invoke RasHangUp, l_RASCONN.hrasconn
TheEnd:
Enjoy!!!

Regards,  P1   :8)

ragdog

thx this works fine! :U

i have a another problem with get the online status
if the connection is online than should it show (me) the messadgebox


mov RASConnectionStatus.dwSize,sizeof(RASCONNSTATUS)
invoke RasGetConnectStatus,RasDialConn.hrasconn,offset RASConnectionStatus
.IF RASConnectionStatus.rasconnstate == RASCS_Connected
invoke MessageBox,0,0,0,MB_OK
.endif