zoukankan      html  css  js  c++  java
  • 临时记录

    linux捕捉异常: signal函数 

     

    HANDLE handle;//process handle

    HWND apphwnd;//window handle

     

    窗口嵌套

     

    /*************Global functions for hosting******************/

    //Function to enumerate all windows.

    int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)

    {

    DWORD pID;

    DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);//get process id

    if (TpID == (DWORD)param)

        {

    apphwnd=hwnd;//hwnd is the window handle

    return false;

        }

    return true;

    }

     

     

    //Functio to start a process and return the process handle

    HANDLE StartProcess(LPCTSTR program, LPCTSTR args)

    {

     

    HANDLE hProcess = NULL;

    PROCESS_INFORMATION processInfo;

    STARTUPINFO startupInfo;

    ::ZeroMemory(&startupInfo, sizeof(startupInfo));

    startupInfo.cb = sizeof(startupInfo);

    if(::CreateProcess(program, (LPTSTR)args,

    NULL, // process security

    NULL, // thread security

    FALSE, // no inheritance

    0, // no startup flags

    NULL, // no special environment

    NULL, // default startup directory

    &startupInfo,

    &processInfo))

    { /* success */

                Sleep(5000);

                 ::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);//Iterate all windows

         hProcess = processInfo.hProcess;

    } /* success */

    return hProcess;

    }

     

    /**********************************************************/

    //handle for host menu

    void CHostMSPaintDlg::OnActionHostmspaint()

    {

        CRect rect;

        GetClientRect(&rect);//get our dialog size into rect

     

        handle=StartProcess("C:\WINDOWS\system32\mspaint.exe", "");//Start ms paint

        if(apphwnd!=NULL)//check for window handle

        {

            ::SetParent(apphwnd,m_hWnd);//set parent of ms paint to our dialog.

            SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);//eraze title of ms paint window.

            //Positioning ms paint.

            ::MoveWindow(apphwnd, rect.left, rect.top,rect.right, rect.bottom, true);

                

        }

        else//no window for our process

            MessageBox("Cannot find Window");    

    }

     

    //handle for kill process menu.

    void CHostMSPaintDlg::OnActionKillprocess()

    {

        TerminateProcess(handle,0);    //kill the process using handle

    }

     

     

    宏使用

     

    #include <stdio.h>

     

    #define chSTR2(x) #x

    #define chSTR(x) chSTR2(x)

    #define chMSG(desc) (__FILE__ "(" chSTR(__LINE__) "):" #desc)

     

    int main(int argc, _TCHAR* argv[])

    {

    printf("%s " , chMSG(hello));

    return 0;

    }

  • 相关阅读:
    Centos7安装teamviewer 32/64位
    Centos7安装32位库用来安装32位软件程序
    linux环境下配置mysql双主复制
    zabbix自定义触发器进行监控
    VM安装系统时提示硬件不支持(unsupported hardware detected)
    mysql新建用户在本地无法登录
    msyql开启慢查询以及分析慢查询
    zabbix怎么把英文界面换成中文
    xencenter如何安装系统
    mysql优化查询
  • 原文地址:https://www.cnblogs.com/ant-wjf/p/7020276.html
Copyright © 2011-2022 走看看