{"id":3748,"date":"2021-12-11T06:10:28","date_gmt":"2021-12-11T06:10:28","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=3748"},"modified":"2021-12-11T06:41:30","modified_gmt":"2021-12-11T06:41:30","slug":"2c-wxwidgets-process-control","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2021\/12\/11\/2c-wxwidgets-process-control\/","title":{"rendered":"2c.wxWidgets &#8211; Process Control"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>wxWidgets provides various functions to interact with the OS and call other applications. <\/p>\n\n\n\n<p><em>wxShell() <\/em>is used to run OS level commands. <em>wxExecute()<\/em> can also do the same thing, but it has the capability of running asynchronously and also capture the application output. <em>wsExit() <\/em>terminates the current program.<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pcontrol.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n#include &lt;wx\/app.h&gt;\n\nint main(int argc, char **argv) {\n\twxInitialize();\n\twxExecute(wxT(&quot;cal 2022&quot;), wxEXEC_ASYNC);\n\twxExecute(wxT(&quot;ls -l&quot;));\n\twxShell(wxT(&quot;cal&quot;));\n\tunsigned long pid = wxGetProcessId();\n\twxString strPid = wxString::Format(wxT(&quot;Process id=%zu&quot;), pid);\n\twxPuts(strPid);\n\n\twxUninitialize();\n\twxExit();\n\t\n\n}\n<\/pre><\/div>\n\n\n<p>The output is given below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>                        2022   January               February               March          <\/code>\n Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  \n                    1         1  2  3  4  5         1  2  3  4  5  \n  2  3  4  5  6  7  8   6  7  8  9 10 11 12   6  7  8  9 10 11 12  \n  9 10 11 12 13 14 15  13 14 15 16 17 18 19  13 14 15 16 17 18 19  \n 16 17 18 19 20 21 22  20 21 22 23 24 25 26  20 21 22 23 24 25 26  \n 23 24 25 26 27 28 29  27 28                 27 28 29 30 31        \n 30 31                                                             \n <code>   April                  May                   June          <\/code>\n Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  \n                 1  2   1  2  3  4  5  6  7            1  2  3  4  \n  3  4  5  6  7  8  9   8  9 10 11 12 13 14   5  6  7  8  9 10 11  \n 10 11 12 13 14 15 16  15 16 17 18 19 20 21  12 13 14 15 16 17 18  \n 17 18 19 20 21 22 23  22 23 24 25 26 27 28  19 20 21 22 23 24 25  \n 24 25 26 27 28 29 30  29 30 31              26 27 28 29 30        \n <code>    July                 August              September        <\/code>\n Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  \n                 1  2      1  2  3  4  5  6               1  2  3  \n  3  4  5  6  7  8  9   7  8  9 10 11 12 13   4  5  6  7  8  9 10  \n 10 11 12 13 14 15 16  14 15 16 17 18 19 20  11 12 13 14 15 16 17  \n 17 18 19 20 21 22 23  21 22 23 24 25 26 27  18 19 20 21 22 23 24  \n 24 25 26 27 28 29 30  28 29 30 31           25 26 27 28 29 30     \n 31                                                                \n <code>  October               November              December        <\/code>\n Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  \n                    1         1  2  3  4  5               1  2  3  \n  2  3  4  5  6  7  8   6  7  8  9 10 11 12   4  5  6  7  8  9 10  \n  9 10 11 12 13 14 15  13 14 15 16 17 18 19  11 12 13 14 15 16 17  \n 16 17 18 19 20 21 22  20 21 22 23 24 25 26  18 19 20 21 22 23 24  \n 23 24 25 26 27 28 29  27 28 29 30           25 26 27 28 29 30 31  \n 30 31                                                             \n total 48024\n -rwxrwxr-x 1 amit amit 7016344 Dec 11 10:55 console\n -rw-rw-r-- 1 amit amit     392 Dec 11 10:55 console.cpp\n -rwxrwxr-x 1 amit amit 7022224 Dec 11 10:42 datetime\n -rw-rw-r-- 1 amit amit    1023 Dec 11 10:41 datetime.cpp\n -rwxrwxr-x 1 amit amit 7016456 Dec 11 10:43 directory\n -rw-rw-r-- 1 amit amit     805 Dec 11 10:42 directory.cpp\n -rw-rw-r-- 1 amit amit      63 Dec 11 10:43 file.dat\n -rwxrwxr-x 1 amit amit 7024624 Dec 11 10:43 filereadwrite\n -rw-rw-r-- 1 amit amit     811 Dec 11 10:42 filereadwrite.cpp\n -rwxrwxr-x 1 amit amit 7017216 Dec 11 10:44 pcontrol\n -rw-rw-r-- 1 amit amit     389 Dec 11 10:42 pcontrol.cpp\n -rwxrwxr-x 1 amit amit 7010784 Dec 11 10:44 platform\n -rw-rw-r-- 1 amit amit     275 Dec 11 10:42 platform.cpp\n -rwxrwxr-x 1 amit amit 7023184 Dec 11 10:58 strings\n -rw-rw-r-- 1 amit amit     920 Dec 11 10:58 strings.cpp\n    December 2021      \n Su Mo Tu We Th Fr Sa  \n           1  2  3  4  \n  5  6  7  8  9 10 11  \n 12 13 14 15 16 17 18  \n 19 20 21 22 23 24 25  \n 26 27 28 29 30 31     \n Process id=16216<\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW wxWidgets provides various functions to interact with the OS and call other applications. wxShell() is used to run OS level commands. wxExecute() can also <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2021\/12\/11\/2c-wxwidgets-process-control\/\" title=\"2c.wxWidgets &#8211; Process Control\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":3595,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,365],"tags":[],"class_list":["post-3748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cc","category-wxwidgets"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=3748"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3748\/revisions"}],"predecessor-version":[{"id":3764,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3748\/revisions\/3764"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/3595"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=3748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=3748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=3748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}