Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
BlackDice12-Nov-04 2:43
BlackDice12-Nov-04 2:43 
GeneralRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
Member 124237313-Nov-04 5:12
Member 124237313-Nov-04 5:12 
AnswerRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
David Crow12-Nov-04 3:33
David Crow12-Nov-04 3:33 
GeneralRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
Member 124237313-Nov-04 5:32
Member 124237313-Nov-04 5:32 
GeneralRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
David Crow13-Nov-04 5:52
David Crow13-Nov-04 5:52 
GeneralRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
Member 124237314-Nov-04 11:23
Member 124237314-Nov-04 11:23 
GeneralRe: How can several panels of a CTabCtrl share the same CComboBox ? Pin
David Crow15-Nov-04 3:41
David Crow15-Nov-04 3:41 
GeneralRe: TCP/IP Sockets Pin
22491711-Nov-04 23:07
22491711-Nov-04 23:07 
Disable network.

A com solution

<br />
#define _WIN32_WINNT 0x0502<br />
<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <objbase.h><br />
#include <netcon.h><br />
<br />
//Check the HRESULT of COM calls and exit on ERROR<br />
#define CheckHR(info) \<br />
    { \<br />
        HRESULT hr = (info); \<br />
        if(FAILED(hr)) \<br />
        { \<br />
               if ( hr != 0x800704D5 ) \<br />
               { \<br />
                    printf("ERROR"); \<br />
                    exit(1); \<br />
               } \<br />
        }\<br />
    }<br />
<br />
<br />
typedef enum<br />
{<br />
     DISABLE = 0,                    //Disable the Network Connection<br />
          ENABLE = 1,                    //Enable the Network Connection<br />
          PORT_STATUS = 2,     //Get the Network Port Status Command<br />
          LINK_STATUS = 3,     //Get the Network Link Status Command<br />
          ENDIS_PORT = 4          //Disable/Enable Network Connection Command<br />
}PORTSTATUS;<br />
<br />
<br />
<br />
void main(int argc, char** argv)<br />
{<br />
    INetConnectionManager*          pManager;<br />
    INetConnection*                    pConnection;<br />
    IEnumNetConnection*               pEnum;<br />
    INetConnectionConnectUi*     pConnectionUI;<br />
<br />
    ULONG     celtFetched;<br />
<br />
     BOOL bFoundInterface = FALSE;<br />
     int     nPortStatus = -1;<br />
     int nCmd = -1;<br />
     wchar_t ifname[100];<br />
<br />
<br />
     if (argc <= 2 )<br />
     {<br />
          printf("ERROR");<br />
          return;<br />
     }<br />
<br />
     swprintf(ifname,L"%S",argv[1]); //Copy the interface name "Local Area Connection"<br />
     nCmd = atoi(argv[2]);     //Copy the Command<br />
     if ( argc == 4 )<br />
     {<br />
          nPortStatus = ( argv[3][0] == '1' ) ? 1:0 ;     //Copy the Status to be Set<br />
     }<br />
<br />
<br />
     //Initialize COM<br />
    CheckHR( CoInitialize(NULL) );<br />
     //Get an Instance of INetConnectionManager<br />
    CheckHR( CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pManager) );<br />
    //Enumerate the Network Connections<br />
    CheckHR( pManager->EnumConnections(NCME_DEFAULT, &pEnum) );<br />
     //Release the InetConnectionManager<br />
    pManager->Release();<br />
   <br />
    while( pEnum->Next(1, &pConnection, &celtFetched) == S_OK )<br />
    {<br />
        NETCON_PROPERTIES* properties;<br />
          //Get the properties of a Network Connection<br />
        CheckHR( pConnection->GetProperties(&properties) );<br />
          //Check the Interface Name<br />
          if ( (wcscmp(properties->pszwName,ifname)) == 0 )<br />
          {<br />
               bFoundInterface = TRUE;<br />
               switch(nCmd)<br />
               {<br />
               case PORT_STATUS:<br />
               case LINK_STATUS:<br />
                    {<br />
                         switch(properties->Status)<br />
                         {<br />
                         case NCS_DISCONNECTED:<br />
                         case NCS_DISCONNECTING:<br />
                         case NCS_HARDWARE_NOT_PRESENT:<br />
                         case NCS_HARDWARE_DISABLED:<br />
                         case NCS_HARDWARE_MALFUNCTION:<br />
                         case NCS_AUTHENTICATION_FAILED:<br />
                         case NCS_INVALID_ADDRESS:<br />
                         case NCS_CREDENTIALS_REQUIRED:<br />
                              printf("Port is not Functioning");<br />
                              break;<br />
                         case NCS_CONNECTED:<br />
                              {<br />
                                   if ( nCmd == PORT_STATUS )<br />
                                        printf("Port is UP");<br />
                                   else<br />
                                        printf("Link is UP");<br />
                              }<br />
                              break;<br />
                         case NCS_MEDIA_DISCONNECTED:<br />
                              printf("MEDIADISCONNECTED");<br />
                              break;<br />
                         default:<br />
                              printf("ERROR");<br />
                              break;<br />
                         }<br />
                    }<br />
                    break;<br />
               case ENDIS_PORT:<br />
                    {<br />
                         switch(nPortStatus)<br />
                         {<br />
                         case DISABLE:<br />
                              {<br />
                                   if(SUCCEEDED(pConnection->QueryInterface(IID_INetConnectionConnectUi, (void**)pConnectionUI)))<br />
                                   {<br />
                                        pConnectionUI->SetConnection(pConnection);<br />
                                        pConnectionUI->Disconnect(NULL, NCUC_NO_UI);<br />
                                        pConnectionUI->Release();<br />
                                   }<br />
                                   else<br />
                                   {<br />
                                        CheckHR( pConnection->Disconnect() );<br />
                                   }<br />
                              }<br />
                              break;<br />
                         case ENABLE:<br />
                              {<br />
                                   if(SUCCEEDED(pConnection->QueryInterface(IID_INetConnectionConnectUi, (void**)pConnectionUI)))<br />
                                   {<br />
                                        pConnectionUI->SetConnection(pConnection);<br />
                                        pConnectionUI->Connect(NULL, NCUC_NO_UI);<br />
                                        pConnectionUI->Release();<br />
                                   }<br />
                                   else<br />
                                   {<br />
                                        CheckHR( pConnection->Connect() );<br />
                                   }<br />
                              }<br />
                              break;<br />
                         default:<br />
                              printf("ERROR");<br />
                              break;<br />
                         }<br />
                    }<br />
                    break;<br />
               default:<br />
                    printf("ERROR");<br />
                    break;<br />
               }<br />
               CoTaskMemFree(properties);<br />
               pConnection->Release();<br />
               break;<br />
          }<br />
          else<br />
          {<br />
               CoTaskMemFree(properties);<br />
               pConnection->Release();<br />
               continue;<br />
          }<br />
    }<br />
     if ( !bFoundInterface )<br />
          printf("ERROR");<br />
<br />
    pEnum->Release();<br />
    CoUninitialize();<br />
}<br />
<br />





There is no spoon.

mail
GeneralCreate device driver Pin
snthomas11-Nov-04 22:41
snthomas11-Nov-04 22:41 
GeneralRe: Create device driver Pin
22491712-Nov-04 0:54
22491712-Nov-04 0:54 
GeneralMain handle of MFC dialog Pin
Kreatief11-Nov-04 22:25
Kreatief11-Nov-04 22:25 
GeneralRe: Main handle of MFC dialog Pin
22491711-Nov-04 22:47
22491711-Nov-04 22:47 
GeneralRe: Main handle of MFC dialog Pin
Kreatief12-Nov-04 0:46
Kreatief12-Nov-04 0:46 
GeneralRe: Main handle of MFC dialog Pin
BlackDice12-Nov-04 2:46
BlackDice12-Nov-04 2:46 
GeneralRe: Main handle of MFC dialog Pin
David Crow12-Nov-04 3:35
David Crow12-Nov-04 3:35 
GeneralRe: Main handle of MFC dialog Pin
Kreatief12-Nov-04 4:51
Kreatief12-Nov-04 4:51 
Generalaaaaaaaaah.....help!!!!!my OnSetCursor()....doesnt work at all places!!!!!! Pin
namaskaaram11-Nov-04 22:19
namaskaaram11-Nov-04 22:19 
Generalconvert _int64 to double Pin
Member 147636711-Nov-04 22:15
Member 147636711-Nov-04 22:15 
GeneralRe: convert _int64 to double Pin
David Crow12-Nov-04 3:47
David Crow12-Nov-04 3:47 
GeneralTCP/IP Sockets Pin
QuaKx11-Nov-04 22:08
QuaKx11-Nov-04 22:08 
GeneralWindow without vertical borders Pin
Sara Burns11-Nov-04 21:57
Sara Burns11-Nov-04 21:57 
QuestionHow to hide an application on Win 9x/Me ? Pin
chauhoangtrung11-Nov-04 20:16
chauhoangtrung11-Nov-04 20:16 
AnswerRe: How to hide an application on Win 9x/Me ? Pin
David Crow12-Nov-04 3:51
David Crow12-Nov-04 3:51 
GeneralRe: How to hide an application on Win 9x/Me ? Pin
chauhoangtrung14-Nov-04 14:34
chauhoangtrung14-Nov-04 14:34 
GeneralRe: How to hide an application on Win 9x/Me ? Pin
David Crow15-Nov-04 4:41
David Crow15-Nov-04 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.