{"id":35,"date":"2013-07-26T12:29:30","date_gmt":"2013-07-26T12:29:30","guid":{"rendered":"https:\/\/praveenkatiyar.wordpress.com\/?p=35"},"modified":"2013-07-26T12:29:30","modified_gmt":"2013-07-26T12:29:30","slug":"interoperability-with-winodws-api-1-of-n","status":"publish","type":"post","link":"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/07\/26\/interoperability-with-winodws-api-1-of-n\/","title":{"rendered":"Interoperability with Winodws API (1 of N)"},"content":{"rendered":"<p>In this article I will explain, how one can call windows API, from managed world. let\u2019s define the signatures of windows API for managed world.<\/p>\n<h3>Calling a Win32 MessageBox function from Managed Word<\/h3>\n<p>\/\/****************************<\/p>\n<p>\/\/ MyProgram.cs<\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">namespace MyManagedProgram&#160;&#160; {&#160; \/\/1<\/font><\/strong><\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">class Program&#160;&#160; { \/\/ 2       <br \/>static void Main(string[] args)&#160;&#160; { \/\/3<\/font><\/strong><\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">Win32DllWrapper.MsgBox(0, &quot;This Text has been sent from&#160; Managed World&quot;,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Win32 Messsage Box&quot;, 0);<\/font><\/strong><\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">} \/\/3 <\/font><\/strong><\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">}&#160; \/\/2 <\/font><\/strong><\/p>\n<h4>\/\/\/defining the helper class<\/h4>\n<p>\/\/\/define a helper class which will contain a functions for<\/p>\n<p><font color=\"#0000ff\" face=\"Courier New\"><strong>public class Win32DllWrapper&#160;&#160; {&#160;&#160;&#160; \/\/4       <br \/>\/\/&#160; Standard Functions from Windows API.        <br \/>[DllImport(&quot;User32.dll&quot;, EntryPoint = &quot;MessageBox&quot;, CharSet = CharSet.Auto)]        <br \/>public static extern int MsgBox(int hWnd, String text, String caption, uint type);<\/strong><\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Courier New\"><strong>}&#160; \/\/4<\/strong><\/font><\/p>\n<p><strong><font color=\"#0000ff\" face=\"Courier New\">}&#160; \/\/ 1<\/font><\/strong><\/p>\n<p><strong>compile and execute<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I will explain, how one can call windows API, from managed world. let\u2019s define the signatures of windows API for managed world. Calling a Win32 MessageBox function from Managed Word \/\/**************************** \/\/ MyProgram.cs namespace MyManagedProgram&#160;&#160; {&#160; \/\/1 class Program&#160;&#160; { \/\/ 2 static void Main(string[] args)&#160;&#160; { \/\/3 Win32DllWrapper.MsgBox(0, &quot;This Text has&hellip; <a class=\"more-link\" href=\"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/07\/26\/interoperability-with-winodws-api-1-of-n\/\">Continue reading <span class=\"screen-reader-text\">Interoperability with Winodws API (1 of N)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3,9,10,15],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-net","category-codeproject","category-interoperability","category-marshaling","category-win32","entry"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":0,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}