zoukankan      html  css  js  c++  java
  • VC远控(三)磁盘显示

    服务端:

    发送与接收命令

    DWORD WINAPI SLisen(LPVOID lparam)
    {
        SOCKET client = (SOCKET)lparam;
        COMMAND command;
        while (true)
        {
            memset((char *)&command, 0, sizeof(command));
            if (recv(client, (char *)&command, sizeof(command), 0) == SOCKET_ERROR)
            {
                cout<<"Client order incorrect"<<endl;
                break;
            }
            else
            {
                cout<<"Client order correct"<<endl;
                switch (command.ID)
                {
                case GetDriver:
                    GetDriverProc(command, client);
                    break;
                default:
                    break;
                }
            }
        }
        closesocket(client);
        return 0;
    }

    逻辑处理

    DWORD GetDriverProc(COMMAND command, SOCKET client)
    {
        COMMAND cmd;
        memset((char *)&cmd, 0, sizeof(cmd));
        cmd.ID = GetDriver;
    
        for (char i = 'A'; i <= 'Z'; i++)
        {
            char x[26] = {i, ':', ''};
            
            UINT Type = GetDriveType(x);
            if (Type == DRIVE_FIXED || Type == DRIVE_REMOVABLE || Type == DRIVE_CDROM)
            {
                memset((char *)cmd.lparam, 0, sizeof(cmd.lparam));
                strcpy((char *)cmd.lparam, x);
                if (send(client, (char*)&cmd, sizeof(cmd), 0) == SOCKET_ERROR)
                {
                    cout<<"Feedback failed"<<endl;
                }
            }
        }
        return 0;
    }

    客户端

    发送与接收数据

    DWORD WINAPI CLisen(LPVOID lparam)
    {
        CRemoteClientDlg* dlg = (CRemoteClientDlg *) lparam;
        COMMAND cmd;
        memset((char *)&cmd, 0, sizeof(cmd));
        while (true)
        {
            memset((char *)&cmd, 0, sizeof(cmd));
            if (recv(server, (char *)&cmd, sizeof(cmd), 0) == SOCKET_ERROR)
            {
                break;
            }
            else
            {
                switch (cmd.ID)
                {
                case GetDriver:
                    dlg->GetDriverProc(cmd.lparam);
                    break;
                default:
                    break;
                }
            }
        }
        closesocket(server);
        return 0;
    }

    逻辑处理

    DWORD CRemoteClientDlg::GetDriverProc(BYTE* DATA)
    {
        char buff[1024];
        strcpy(buff, (char*)DATA);
    
        //将接受到的磁盘信息插入到TreeView中。
        m_tree.InsertItem(buff, 1, 1, m_hRoot, 0);
        //展开收缩子目录,初始状态为展开的。
        m_tree.Expand(m_hRoot, TVE_EXPAND);
        return 0;
    }

    treeView树形显示

        DWORD dwStyle = GetWindowLong(m_tree.m_hWnd, GWL_STYLE);
        dwStyle |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
        SetWindowLong(m_tree.m_hWnd, GWL_STYLE, dwStyle);

  • 相关阅读:
    General part中方向选取的作用
    mount part中位置的作用
    关于zero pivot
    Revit二次开发示例:ModelessForm_ExternalEvent
    elasticsearch6.4 memory locking requested for elasticsearch process but memory is not locked
    百度网盘 http://pandownload.com/index.html
    MySQL 5.7主从复制从零开始设置及全面详解——实现多线程并行同步,解决主从复制延迟问题!
    linux 系统优化
    服务器cpu过高修复:操作系统内核bug导致
    Jvm中时区设置方式
  • 原文地址:https://www.cnblogs.com/zhangtingkuo/p/3430520.html
Copyright © 2011-2022 走看看