elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  [c]aporte ping con interfaz grafica
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [c]aporte ping con interfaz grafica  (Leído 2,266 veces)
daryo


Desconectado Desconectado

Mensajes: 1.070



Ver Perfil WWW
[c]aporte ping con interfaz grafica
« en: 3 Julio 2013, 16:06 pm »



Código
  1. #include <windows.h>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <iostream>
  5.  
  6. int MN_MENSAJE=1024;
  7. int MN_SALIR=1025;
  8. HINSTANCE miinstance;
  9. /*  Declare Windows procedure  */
  10. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  11.  
  12. /*  Make the class name into a global variable  */
  13. char szClassName[ ] = "CodeBlocksWindowsApp";
  14.  
  15. int WINAPI WinMain (HINSTANCE hThisInstance,
  16.                     HINSTANCE hPrevInstance,
  17.                     LPSTR lpszArgument,
  18.                     int nCmdShow)
  19. {
  20.    HWND hwnd;               /* This is the handle for our window */
  21.    MSG messages;            /* Here messages to the application are saved */
  22.    WNDCLASSEX wincl;        /* Data structure for the windowclass */
  23.    miinstance=hThisInstance;
  24.  
  25.    /* The Window structure */
  26.    wincl.hInstance = hThisInstance;
  27.    wincl.lpszClassName = szClassName;
  28.    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  29.    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  30.    wincl.cbSize = sizeof (WNDCLASSEX);
  31.  
  32.    /* Use default icon and mouse-pointer */
  33.    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  34.    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  35.    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  36.    wincl.lpszMenuName = NULL;                 /* No menu */
  37.    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  38.    wincl.cbWndExtra = 0;                      /* structure or the window instance */
  39.    /* Use Windows's default colour as the background of the window */
  40.    wincl.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(239,239,239));
  41.  
  42.    /* Register the window class, and if it fails quit the program */
  43.    if (!RegisterClassEx (&wincl))
  44.        return 0;
  45.  
  46.    /* The class is registered, let's create the program*/
  47.    hwnd = CreateWindowEx (
  48.           0,                   /* Extended possibilites for variation */
  49.           szClassName,         /* Classname */
  50.           "Ping",       /* Title Text */
  51.           WS_OVERLAPPEDWINDOW, /* default window */
  52.           CW_USEDEFAULT,       /* Windows decides the position */
  53.           CW_USEDEFAULT,       /* where the window ends up on the screen */
  54.           544,                 /* The programs width */
  55.           275,                 /* and height in pixels */
  56.           HWND_DESKTOP,        /* The window is a child-window to desktop */
  57.           NULL,                /* No menu */
  58.           hThisInstance,       /* Program Instance handler */
  59.           NULL                 /* No Window Creation data */
  60.           );
  61.  
  62.  
  63.    /* Make the window visible on the screen */
  64.    ShowWindow (hwnd, nCmdShow);
  65.  
  66.    /* Run the message loop. It will run until GetMessage() returns 0 */
  67.    while (GetMessage (&messages, NULL, 0, 0))
  68.    {
  69.        /* Translate virtual-key messages into character messages */
  70.        TranslateMessage(&messages);
  71.        /* Send message to WindowProcedure */
  72.        DispatchMessage(&messages);
  73.    }
  74.  
  75.    /* The program return-value is 0 - The value that PostQuitMessage() gave */
  76.    return messages.wParam;
  77. }
  78.  
  79.  
  80. /*  This function is called by the Windows function DispatchMessage()  */
  81.  
  82. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  83. {
  84.    const int MN_MENSAJE=1025;
  85.    HMENU menu=CreateMenu();
  86.    HMENU submenu=CreateMenu();
  87.    switch (message)                  /* handle the messages */
  88.    {
  89.        case WM_CREATE:
  90.            AppendMenu(submenu,MF_STRING,MN_MENSAJE,"&creditos");
  91.            AppendMenu(menu,MF_STRING|MF_POPUP,(UINT)submenu,"&Acerca de");
  92.            SetMenu(hwnd,menu);
  93.            static HFONT hFont = CreateFont(14, 0, 0, 0, 100, 0, 0, 0,0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "Helv");
  94.            static HWND texto = CreateWindowEx(0,"STATIC", "Inserte la ip:", WS_CHILD|WS_VISIBLE, 0, 0, 90, 25, hwnd, 0, miinstance, NULL);
  95.            static HWND campo = CreateWindowEx(0,"EDIT", "", WS_CHILD|WS_VISIBLE, 0, 45, 105, 12, hwnd, 0, miinstance, NULL);
  96.            static HWND boton = CreateWindowEx(NULL,"BUTTON","hacer ping",WS_CHILD|WS_VISIBLE|WS_TABSTOP,110,42,100,20,hwnd,0,miinstance,NULL);
  97.            static HWND text2 = CreateWindowEx(0,"STATIC", "Salida del comando:", WS_CHILD|WS_VISIBLE, 250, 0, 130, 25, hwnd, 0, miinstance, NULL);
  98.            static HWND text3 = CreateWindowEx(0,"STATIC", " ", WS_CHILD|WS_VISIBLE, 250, 30, 230, 225, hwnd, 0, miinstance, NULL);
  99.            SendMessage(texto,WM_SETFONT,(WPARAM)hFont,true);
  100.            SendMessage(boton,WM_SETFONT,(WPARAM)hFont,true);
  101.            SendMessage(campo, WM_SETFONT, (WPARAM) hFont, true);
  102.            SendMessage(text2, WM_SETFONT, (WPARAM) hFont, true);
  103.            SendMessage(text3, WM_SETFONT, (WPARAM) hFont, true);
  104.            break;
  105.        case WM_COMMAND:
  106.         switch(LOWORD(wParam))
  107.            {
  108.                case MN_MENSAJE:
  109.                MessageBox(hwnd,"codeado por daryo","creditos",MB_OK);
  110.                break;
  111.            }
  112.         if((HWND)lParam==boton)
  113.         {
  114.            FILE *in;
  115.            char ip[100];
  116.            char ping[200]="ping ";
  117.            char n[700];
  118.            char string[700]=" ";
  119.            GetWindowText(campo, ip, 255);
  120.            strcat(ping,ip);
  121.            in=popen(ping,"r");
  122.            while ( fgets(n, 700, in) != NULL )
  123.            {
  124.              strcat(string,n);
  125.            }
  126.             SendMessage(text3, WM_SETTEXT, false, (long int) string);
  127.  
  128.         }
  129.            break;
  130.        case WM_DESTROY:
  131.            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
  132.            break;
  133.        default:                      /* for messages that we don't deal with */
  134.            return DefWindowProc (hwnd, message, wParam, lParam);
  135.    }
  136.  
  137.    return 0;
  138. }
  139.  


En línea

buenas
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Interfaz grafica « 1 2 »
Programación C/C++
danyof 11 7,949 Último mensaje 24 Mayo 2010, 15:08 pm
por danyof
Interfaz Grafica
Programación C/C++
mapers 3 6,311 Último mensaje 8 Marzo 2011, 16:02 pm
por Oblivi0n
Interfaz Gráfica C++
Programación C/C++
Bomb-P 9 5,007 Último mensaje 20 Abril 2013, 16:06 pm
por 0xDani
Interfaz Grafica
Programación C/C++
JohnMcb 1 2,463 Último mensaje 20 Abril 2013, 02:08 am
por 85
[APORTE] Pingadoo: Aplicación cliente ping.
.NET (C#, VB.NET, ASP)
El Benjo 0 1,966 Último mensaje 30 Agosto 2015, 20:46 pm
por El Benjo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines