Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help me DisConnect Internet use Ras

Help me DisConnect Internet use Ras

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    so0_lanhlung2
    wrote on last edited by
    #1

    #include "stdio.h"
    #include "conio.h"
    #include "windows.h"
    #include "Wininet.h"
    #include "Ras.h"
    #include "raserror.h"
    #pragma comment(lib, "rasapi32.lib")

    int main()
    {
    LPRASCONN lpRasConn;
    DWORD dwCb=0;
    DWORD dwRet;
    DWORD dwConnections = 0;
    HRASCONN hRasConn;

    lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP\_ZERO\_MEMORY, dwCb);
    
    lpRasConn\[0\].dwSize=sizeof(RASCONN) ;
    
    dwRet = RasEnumConnections(lpRasConn, &dwCb, &dwConnections);
    
    if(dwRet==ERROR\_SUCCESS)
    	for(int i=0 ; i < dwConnections ; i++)
    	{
    		hRasConn= lpRasConn\[i\].hrasconn;
    		BOOL b=RasHangUp(hRasConn);
    	}
    

    // HeapFree(GetProcessHeap(), 0, lpRasConn);
    _getch();

    }

    i don't know where was it wrong? sorry if my english is not well :laugh:

    _ D A 3 Replies Last reply
    0
    • S so0_lanhlung2

      #include "stdio.h"
      #include "conio.h"
      #include "windows.h"
      #include "Wininet.h"
      #include "Ras.h"
      #include "raserror.h"
      #pragma comment(lib, "rasapi32.lib")

      int main()
      {
      LPRASCONN lpRasConn;
      DWORD dwCb=0;
      DWORD dwRet;
      DWORD dwConnections = 0;
      HRASCONN hRasConn;

      lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP\_ZERO\_MEMORY, dwCb);
      
      lpRasConn\[0\].dwSize=sizeof(RASCONN) ;
      
      dwRet = RasEnumConnections(lpRasConn, &dwCb, &dwConnections);
      
      if(dwRet==ERROR\_SUCCESS)
      	for(int i=0 ; i < dwConnections ; i++)
      	{
      		hRasConn= lpRasConn\[i\].hrasconn;
      		BOOL b=RasHangUp(hRasConn);
      	}
      

      // HeapFree(GetProcessHeap(), 0, lpRasConn);
      _getch();

      }

      i don't know where was it wrong? sorry if my english is not well :laugh:

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The for loop is wrong. It looks incomplete.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      S 1 Reply Last reply
      0
      • _ _Superman_

        The for loop is wrong. It looks incomplete.

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        S Offline
        S Offline
        so0_lanhlung2
        wrote on last edited by
        #3

        can you help me indicate that error...i don't know plz :-O

        _ 1 Reply Last reply
        0
        • S so0_lanhlung2

          can you help me indicate that error...i don't know plz :-O

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          :omg: It looks OK now. I guess something is wrong with me today. :^)

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          1 Reply Last reply
          0
          • S so0_lanhlung2

            #include "stdio.h"
            #include "conio.h"
            #include "windows.h"
            #include "Wininet.h"
            #include "Ras.h"
            #include "raserror.h"
            #pragma comment(lib, "rasapi32.lib")

            int main()
            {
            LPRASCONN lpRasConn;
            DWORD dwCb=0;
            DWORD dwRet;
            DWORD dwConnections = 0;
            HRASCONN hRasConn;

            lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP\_ZERO\_MEMORY, dwCb);
            
            lpRasConn\[0\].dwSize=sizeof(RASCONN) ;
            
            dwRet = RasEnumConnections(lpRasConn, &dwCb, &dwConnections);
            
            if(dwRet==ERROR\_SUCCESS)
            	for(int i=0 ; i < dwConnections ; i++)
            	{
            		hRasConn= lpRasConn\[i\].hrasconn;
            		BOOL b=RasHangUp(hRasConn);
            	}
            

            // HeapFree(GetProcessHeap(), 0, lpRasConn);
            _getch();

            }

            i don't know where was it wrong? sorry if my english is not well :laugh:

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            thanhl0v3 wrote:

            i don't know where was it wrong?

            Neither do we. Why don't you bother telling is what is happening vs. what is supposed to happen.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Man who follows car will be exhausted." - Confucius

            1 Reply Last reply
            0
            • S so0_lanhlung2

              #include "stdio.h"
              #include "conio.h"
              #include "windows.h"
              #include "Wininet.h"
              #include "Ras.h"
              #include "raserror.h"
              #pragma comment(lib, "rasapi32.lib")

              int main()
              {
              LPRASCONN lpRasConn;
              DWORD dwCb=0;
              DWORD dwRet;
              DWORD dwConnections = 0;
              HRASCONN hRasConn;

              lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP\_ZERO\_MEMORY, dwCb);
              
              lpRasConn\[0\].dwSize=sizeof(RASCONN) ;
              
              dwRet = RasEnumConnections(lpRasConn, &dwCb, &dwConnections);
              
              if(dwRet==ERROR\_SUCCESS)
              	for(int i=0 ; i < dwConnections ; i++)
              	{
              		hRasConn= lpRasConn\[i\].hrasconn;
              		BOOL b=RasHangUp(hRasConn);
              	}
              

              // HeapFree(GetProcessHeap(), 0, lpRasConn);
              _getch();

              }

              i don't know where was it wrong? sorry if my english is not well :laugh:

              A Offline
              A Offline
              Alain Rist
              wrote on last edited by
              #6

              Hi,

              thanhl0v3 wrote:

              dwCb=0; // ... lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwCb);

              You allocate a block of zero size, so it's unlikely useful :) cheers, AR

              When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups