ShellExecute transfer parameters to the procedure

Source: Internet
Author: User

Such a program is divided into two parts, one is the referenced program, and the other is the referenced program. The core thing is also relatively simple
Reference others, need to pass parameters CString exepath; CString parampath; getdlgitemtext(idc_exepath,exepath); getdlgitemtext(idc_params,parampath); ShellExecute(This,m_hwnd,"open",exepath,Parampath ,"",sw_show );
Referenced by others, need to read parameters //Get parameters passed by other programs CString strcommand = getcommandline();Get a thing like this, split up or pattern recognition, and you get the results. This approach, although feasible, is difficult to control, and it is best to be able to handle it in a message-passing manner. In the process of running the program, how to pass parameters? Windows is a message loop, and can be done through this mechanism. What you do is to pass the parameters between the programs, that is, interprocess communication. Reference to the relevant information, found the solution. Perhaps this time, to pass the custom message is not good to do, or rely on the system's message. Data displayone message is Wm_settext. one message is wm_copydata. Can achieve the results, I have also tested. ComparedWm_settext may be the main transmission of text, whileWm_copydata is more about passing data. key code, send side void caadlg::onbnclickedok() { //TODO: Add control notification handler code here CWnd *pWnd=CWnd::FindWindow(NULL,_t("Bb")); if(pWnd= =NULL)    { AfxMessageBox((CString)"receiving program is not running!"); return ;    } CString str = _t( "Hello" ); pWnd-SendMessage(wm_settext , 0, (LPARAM) (lpctstr)str );}Receiving end afx_msg LRESULT cbbdlg::onsettextmsg(WPARAM WPARAM, LPARAM LPARAM) { char str[n]; wsprintf( str, "%s", (char*) lParam ); return 0;}Finally, combine the two so that you can pass the values in the program by passing the index of the image. Should be the solution to the problem. The result of the final solution is the ability to directly transfer the address of the image and open it directly. Through appropriate modification, can be directly used in the current stone slab project. Further research, found in the Doc/view model, this thing is not able to directly identify, even if you want to think of ways. The last way to think about it is to find a dialog box, and then to handle these things in turn.






From for notes (Wiz)

List of attachments

    ShellExecute transfer parameters to the procedure

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.