{"id":176,"date":"2019-09-30T22:29:52","date_gmt":"2019-09-30T19:29:52","guid":{"rendered":"http:\/\/www.potansif.com\/?p=176"},"modified":"2019-10-01T08:54:08","modified_gmt":"2019-10-01T05:54:08","slug":"linux-shellexecute-api-muadili","status":"publish","type":"post","link":"http:\/\/www.potansif.com\/?p=176","title":{"rendered":"Linux : ShellExecute API Muadili"},"content":{"rendered":"<p><b>Soru<\/b>:<\/p>\n<p>Windows&#8217;ta ShellExecute API&#8217;sini kullanarak harici programlar \u00e7al\u0131\u015ft\u0131rabiliyoruz. Ayn\u0131 i\u015flevi Linux ortam\u0131nda nas\u0131l yapabiliriz?<!--more--><\/p>\n<p>Bu hafta Linux&#8217;u biraz kurcalayal\u0131m istedik, san\u0131r\u0131m biraz abartt\u0131k \ud83d\ude42<\/p>\n<p><b>Cevap<\/b><\/p>\n<p>Ya\u015fad\u0131\u011f\u0131m\u0131z problemin iki aya\u011f\u0131 vard\u0131;<\/p>\n<p>Bunlardan birincisi&nbsp;_PAnsiChar tipinin NEXTGEN derleyici direktifi kapsam\u0131nda&nbsp;tan\u0131ml\u0131 olmas\u0131ndan kaynaklan\u0131yordu, yani LINUX, LINUX64 gibi derleyici direktifleri alt\u0131nda do\u011frudan bir tip tan\u0131mlamas\u0131 ile kar\u015f\u0131la\u015famad\u0131m. Bu sorunu a\u015fmak i\u00e7in&nbsp;Type Casting tekni\u011fini kulland\u0131m ve sorunumu bu noktada \u00e7\u00f6zm\u00fc\u015f oldum. Yani&nbsp;<b>PUTF8Char( RawByteString( filename ) )<\/b> tip sarmalamas\u0131yla&nbsp;bu noktay\u0131 a\u015fm\u0131\u015f olduk.<\/p>\n<p>Fakat yine de s\u00f6z konusu klas\u00f6r\u00fc bir pencerede g\u00f6sterme sorununu a\u015fmak gerekiyordu. Bu sorunu a\u015fmak i\u00e7in linux&#8217;ta bu i\u015fler i\u00e7in <b>&#8220;xdg-open&#8221;<\/b>&nbsp;komutunun kullan\u0131lmas\u0131 gerekiyor. Bu komut t\u0131pk\u0131 Windows&#8217;daki gibi <strong>ShellExecute<\/strong>&#8216;nin yapt\u0131\u011f\u0131 i\u015fi konsolda bir komut olarak yerine getiriyor. Sadece bir klas\u00f6r\u00fc a\u00e7mak i\u00e7in de\u011fil, ayn\u0131 zamanda i\u015fletim sisteminin tan\u0131d\u0131\u011f\u0131 dosya tiplerine kar\u015f\u0131l\u0131k gelen ilgili program\u0131 \u00e7a\u011f\u0131rarak dosyalar\u0131 da&nbsp;a\u00e7abiliyor veya bir URL yazd\u0131ysan\u0131z onu browser&#8217;a da y\u00fckleyebiliyor&#8230;<\/p>\n<p>Detayl\u0131 bilgi i\u00e7in a\u015fa\u011f\u0131daki linke bak\u0131labilir.<\/p>\n<p><a href=\"https:\/\/linux.die.net\/man\/1\/xdg-open\">https:\/\/linux.die.net\/man\/1\/xdg-open<\/a><\/p>\n<pre><code>implementation\n\nuses\n&nbsp; &nbsp; System.IniFiles\n&nbsp; {$IFDEF MSWINDOWS}\n&nbsp; , WINAPI.WINDOWS\n&nbsp; , Winapi.ShellAPI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ ShellExecute\n&nbsp; {$ENDIF MSWINDOWS}\n&nbsp; {$IFDEF LINUX64}\n&nbsp; , Posix.Stdlib&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ _system&nbsp; &gt;&nbsp; ShellExecute e\u015fde\u011feri...\n&nbsp; {$ENDIF LINUX64}\n&nbsp; ;\n\n&nbsp; \/\/ .....\n&nbsp; \/\/ .....\n&nbsp; \/\/ .....\n\nprocedure TAna.ShowFolder( aFilePath: TFileName );\nvar\n&nbsp; aPath : String;\nbegin\n&nbsp; aPath := ExtractFilePath(aFilePath);\n&nbsp; {$IFDEF&nbsp; MSWINDOWS}\n&nbsp; &nbsp; ShellExecute( 0, 'open', PChar ( aPath ), '', '', SW_SHOWNORMAL);\n&nbsp; {$ENDIF}\n&nbsp; {$IFDEF LINUX64}\n&nbsp; &nbsp; _system( PUTF8Char( RawByteString( 'xdg-open ' + aPath ) ) );\n&nbsp; {$ENDIF}\nend;\n<\/code><\/pre>\n<p>Sonu\u00e7 olarak hem Windows&#8217;ta hem de Linux&#8217;ta \u00e7al\u0131\u015fan&nbsp;bir program&nbsp;olmu\u015f oldu;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-597 size-full\" src=\"http:\/\/rubicube.com.tr\/wp-content\/uploads\/2018\/09\/rJ5LrV1.gif\" alt=\"\" width=\"1431\" height=\"904\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows&#8217;ta ShellExecute API&#8217;sini kullanarak harici programlar \u00e7al\u0131\u015ft\u0131rabiliyoruz. Ayn\u0131 i\u015flevi Linux ortam\u0131nda nas\u0131l yapabiliriz?<\/p>\n","protected":false},"author":1,"featured_media":211,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-176","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176"}],"version-history":[{"count":1,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":183,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions\/183"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=\/wp\/v2\/media\/211"}],"wp:attachment":[{"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.potansif.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}