[Multi-programming in Windows (command line )]

Source: Internet
Author: User
Tags erro

Command LineProgramYou can also set multiple stopovers. I checked a lot onlineArticleAll of them are in the administrative window. Here I have a command line, and the framework is very simple, as shown below:

 

// VRP. cpp: defines the entry point of the console application. // # Include "stdafx. H "# include" windows. H "# include" VRP. H "DWORD g_dwripthreadid = 0; DWORD g_dwospfthreadid = 0; int _ tmain (INT argc, _ tchar * argv []) {_ tprintf (_ T (" info: VRP is starting... \ n "); lpvoid pvripparameter = NULL; handle hrip = createthread (null, 0, rip_threadproc, pvripparameter, 0, & g_dwripthreadid); If (null = hrip) {_ tprintf (_ T ("erro: Rip thread create failure! \ N "); Return 0;} _ tprintf (_ T (" info: Rip thread create success! \ N ")); //////////////////////////////////////// ///////////// lpvoid pvospfparameter = NULL ;; handle hospf = createthread (null, 0, ospf_threadproc, pvospfparameter, 0, & g_dwospfthreadid); If (null = hospf) {_ tprintf (_ T ("erro: OSPF thread create failure! \ N "); Return 0;} _ tprintf (_ T (" info: OSPF thread create success! \ N ")); //////////////////////////////////////// //// // sleep (2000 ); uint MSG = my_msg; int COUNT = 0; tchar * wparam = new tchar [max_info_size]; // create dynamic MSG lparam iparam = NULL; while (true) {sleep (2000 ); if (0 = count % 2) {_ stprintf (wparam, _ T ("Main-> rip MSG _ % d"), ++ count ); // If (false = postthreadmessage (g_dwripthreadid, MSG, (wparam) wparam, iparam) {_ tprintf (_ T ("erro: P Ostthreadmessage-> rip failure! \ N ") ;}} else {_ stprintf (wparam, _ T (" Main-> ospf msg _ % d "), ++ count ); // If (false = postthreadmessage (g_dwospfthreadid, MSG, (wparam) wparam, iparam) {_ tprintf (_ T ("erro: postthreadmessage-> OSPF failure! \ N ") ;}}// lresult sendmessage (hwnd, uint MSG, wparam, lparam iparam);} closehandle (hrip); closehandle (hospf ); getchar (); Return 0;} // DWORD winapi rip_threadproc (lpvoid lpparam) {// _ tprintf (_ T ("info: rip_task has been created! \ N "); MSG; _ tchar * pinfo = NULL; peekmessage (& MSG, null, wm_user, wm_user, pm_noremove ); // message sending volume uint uimsg = my_msg; int icount = 0; tchar * wparam = new tchar [max_info_size]; // create dynamic MSG lparam iparam = NULL; while (true) {If (getmessage (& MSG, null, 0, 0) // get MSG from Message Queue {Switch (MSG. message) {Case my_msg: pinfo = (_ tchar *) MSG. wparam; _ tprintf (_ T ("Rip: Recv % s \ n"), P Info); break ;}}_ stprintf (wparam, _ T ("Rip-> ospf msg _ % d"), ++ icount); // sleep (2000 ); if (false = postthreadmessage (g_dwospfthreadid, uimsg, (wparam) wparam, iparam) {_ tprintf (_ T ("erro: postthreadmessage-> rip failure! \ N ") ;}}// Delete pinfo; return 0 ;}// DWORD winapi ospf_threadproc (lpvoid lpparam) {// _ tprintf (_ T (" info: ospf_task has been created! \ N "); MSG; _ tchar * pinfo = NULL; peekmessage (& MSG, null, wm_user, wm_user, pm_noremove); While (true) {If (getmessage (& MSG, null, 0, 0) // get MSG from Message Queue {Switch (MSG. message) {Case my_msg: pinfo = (_ tchar *) MSG. wparam; _ tprintf (_ T ("OSPF: Recv % s \ n"), pinfo); break ;}}// Delete pinfo; return 0 ;}

 

 
# Ifndef _ vrp_h _ # DEFINE _ vrp_h _ # define my_msg wm_user + 100 const int Limit = 20; DWORD winapi rip_threadproc (lpvoid lpparam); DWORD winapi limit (lpvoid lpparam)

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.