{"id":400,"date":"2021-12-22T14:57:32","date_gmt":"2021-12-22T11:57:32","guid":{"rendered":"https:\/\/zeratyl.one\/lab\/?p=400"},"modified":"2021-12-22T15:07:08","modified_gmt":"2021-12-22T12:07:08","slug":"%d0%b2%d1%8b%d0%b2%d0%be%d0%b4-%d0%b2-memo-%d0%b2%d0%bc%d0%b5%d1%81%d1%82%d0%be-%d0%ba%d0%be%d0%bc%d0%b0%d0%bd%d0%b4%d0%bd%d0%be%d0%b9-%d1%81%d1%82%d1%80%d0%be%d0%ba%d0%b8","status":"publish","type":"post","link":"https:\/\/zeratyl.one\/lab\/archives\/400","title":{"rendered":"\u0412\u044b\u0432\u043e\u0434 \u0432 Memo \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438"},"content":{"rendered":"<p style=\"text-align: justify;\">\u0418\u043d\u043e\u0439 \u0440\u0430\u0437 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u041f\u041e \u0438\u043b\u0438 \u0436\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 (\u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430) \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u0443\u0442\u0438\u043b\u0438\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a &#171;\u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443&#187; \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e (\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0438\u043c\u0435\u0435\u0442 GUI). \u041d\u0438\u0436\u0435 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0443 (\u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f) \u043f\u043e \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0443 \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 Memo.<\/p>\n<p><!--more--><\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<blockquote><p>void cmdToMemo(String App)<br \/>\n{<\/p>\n<p style=\"padding-left: 40px;\">#define READ_BUFFER_SIZE 1024<br \/>\nString AppName = App;<br \/>\nSECURITY_ATTRIBUTES Security;<br \/>\nHANDLE ReadPipe, WritePipe;<br \/>\nSTARTUPINFO Start;<br \/>\nTProcessInformation ProcessInfo;<br \/>\nchar *Buffer, Data;<br \/>\nDWORD BytesRead, Apprunning;<br \/>\nint Result, DataSize;<\/p>\n<p style=\"padding-left: 40px;\">Security.nLength = sizeof(TSecurityAttributes);<br \/>\nSecurity.bInheritHandle = true;<br \/>\nSecurity.lpSecurityDescriptor = NULL;<\/p>\n<p style=\"padding-left: 40px;\">if (CreatePipe(&amp;ReadPipe, &amp;WritePipe, &amp;Security, 0))<br \/>\n{<\/p>\n<p style=\"padding-left: 80px;\">Buffer = new char[READ_BUFFER_SIZE + 1];<br \/>\nmemset(&amp;Start, 0, sizeof(Start));<br \/>\nStart.cb = sizeof(Start) ;<br \/>\nStart.hStdOutput = WritePipe;<br \/>\nStart.hStdInput = ReadPipe;<br \/>\nStart.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;<br \/>\nStart.wShowWindow = SW_HIDE;<\/p>\n<p style=\"padding-left: 80px;\">if (CreateProcess(NULL, AppName.c_str(), &amp;Security, &amp;Security, true, NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, &amp;Start, &amp;ProcessInfo))<br \/>\n{<\/p>\n<p style=\"padding-left: 120px;\">do<br \/>\n{<\/p>\n<p style=\"padding-left: 160px;\">Apprunning = WaitForSingleObject(ProcessInfo.hProcess, 100);<br \/>\nApplication-&gt;ProcessMessages();<br \/>\ndo<br \/>\n{<\/p>\n<p style=\"padding-left: 200px;\">Result = PeekNamedPipe(ReadPipe, NULL, 0, NULL, (LPDWORD) &amp;DataSize, NULL);<br \/>\nif ((Result) &amp;&amp; (DataSize))<br \/>\n{<\/p>\n<p style=\"padding-left: 240px;\">if (DataSize &gt; READ_BUFFER_SIZE) DataSize = READ_BUFFER_SIZE;<br \/>\n{<\/p>\n<p style=\"padding-left: 280px;\">ReadFile(ReadPipe, Buffer, DataSize, &amp;BytesRead, NULL);<\/p>\n<p style=\"padding-left: 240px;\">}<\/p>\n<p style=\"padding-left: 240px;\">Buffer[BytesRead] = 0;<br \/>\nOemToAnsi(Buffer, Buffer);<br \/>\nMainForm-&gt;Memo-&gt;Text = MainForm-&gt;Memo-&gt;Text + (AnsiString) Buffer;<\/p>\n<p style=\"padding-left: 200px;\">}<\/p>\n<p style=\"padding-left: 160px;\">}<\/p>\n<p style=\"padding-left: 160px;\">while ((Result) &amp;&amp; (DataSize));<\/p>\n<p style=\"padding-left: 120px;\">}<br \/>\nwhile (Apprunning == WAIT_TIMEOUT);<br \/>\nwhile ((Result) &amp;&amp; (DataSize));<\/p>\n<p style=\"padding-left: 80px;\">}<br \/>\ndelete [] Buffer;<br \/>\nCloseHandle(ProcessInfo.hProcess);<br \/>\nCloseHandle(ProcessInfo.hThread);<br \/>\nCloseHandle(ReadPipe);<br \/>\nCloseHandle(WritePipe);<\/p>\n<p style=\"padding-left: 40px;\">}<br \/>\nreturn;<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u0412 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>main<\/strong> \u044f \u0434\u0435\u043b\u0430\u044e \u0432\u044b\u0437\u043e\u0432 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ipconfig.exe<\/p>\n<blockquote><p>cmdToMemo(\u2033ipconfig.exe\u2033);<\/p><\/blockquote>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/zeratyl.one\/lab\/wp-content\/uploads\/cmdToMemo.jpg\" width=\"416\" height=\"484\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0418\u043d\u043e\u0439 \u0440\u0430\u0437 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u041f\u041e \u0438\u043b\u0438 \u0436\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 (\u0431\u0435\u0437 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430) \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u0443\u0442\u0438\u043b\u0438\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a &#171;\u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443&#187; \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e (\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u0438\u043c\u0435\u0435\u0442 GUI). \u041d\u0438\u0436\u0435 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0443 (\u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f) \u043f\u043e \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0443 \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 Memo&#8230;. <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/zeratyl.one\/lab\/archives\/400\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[65,67,66,64],"class_list":["post-400","post","type-post","status-publish","format-standard","hentry","category-46","tag-c-c","tag-memo","tag-win32","tag-winapi"],"_links":{"self":[{"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/posts\/400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":0,"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"wp:attachment":[{"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zeratyl.one\/lab\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}