<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Example programs</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>Recent changes to Example programs</description><atom:link href="https://sourceforge.net/p/microtone/wiki/Example%20programs/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 17 Nov 2013 12:08:21 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/microtone/wiki/Example%20programs/feed" rel="self" type="application/rss+xml"/><item><title>Example programs modified by Dilshan R Jayakody</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -63,5 +63,6 @@
       .
       .
       .
+      // 5. Close DLL handle.
       CloseHandle(hDLL);
     }   
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dilshan R Jayakody</dc:creator><pubDate>Sun, 17 Nov 2013 12:08:21 -0000</pubDate><guid>https://sourceforge.netc8bfd10b2cf7f9cdf7aa2522d2cb42793094ee5f</guid></item><item><title>Example programs modified by Dilshan R Jayakody</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dilshan R Jayakody</dc:creator><pubDate>Sun, 17 Nov 2013 12:05:32 -0000</pubDate><guid>https://sourceforge.net45f60cc2e4bc195a2148439f80e6a430c860a1f6</guid></item><item><title>Example programs modified by Dilshan R Jayakody</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -3,8 +3,8 @@

 microTone Module example programs are located at *\samples* directory. 

-Code template
--------------
+Code layout
+-----------

 Recommended code layout for static DLL interface (this example based on Lazarus/Delphi):

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dilshan R Jayakody</dc:creator><pubDate>Sun, 17 Nov 2013 12:04:34 -0000</pubDate><guid>https://sourceforge.netf0c6f170033d297b41e4ea01ae5b5a6dee7c6f3c</guid></item><item><title>Example programs modified by Dilshan R Jayakody</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -6,7 +6,7 @@
 Code template
 -------------

-Recommended code layout for static DLL interface (this example use Lazarus):
+Recommended code layout for static DLL interface (this example based on Lazarus/Delphi):

     // 1. load functions from DLL.
     function UTMCreatePacket(OutData : Byte) : Word; stdcall; external 'utm.dll';
@@ -14,7 +14,7 @@
     .
     .
     .
-    // 2. Reset the device using 0x9 command.
+    // 2. Reset the device using 0x9 command. (optional)
     if UTMCreatePacket(9) = 0) then
     begin
       .
@@ -26,3 +26,42 @@
       .
       .
     end;
+
+Recommended code layout for dynamic DLL interface (this example is based on C++):
+
+    // 1. Load DLL into the application.
+    HINSTANCE hDLL = LoadLibrary(L"utm.dll");
+    .
+    .
+    .
+    // 2. Load function from DLL.
+    typedef short (__stdcall *sendP)(char);
+    typedef short (__stdcall *sendByteP)(char);
+
+    sendP _send;
+    sendByteP _sendByte;
+
+    if(hDLL)
+    {
+      _send = (sendP)GetProcAddress(hDLL, "UTMCreatePacket");
+      _sendByte = (sendByteP)GetProcAddress(hDLL, "UTMCreateBytePacket");
+      .
+      .
+      .
+      // 3. Reset the device using 0x9 command. (optional)
+      if(_send(9) == 0)
+      {
+        .
+        .
+        .
+        // 4. Send command to device.
+        if(_sendByte(255) == 0) { ... }
+        .
+        .
+        .
+      }
+      .
+      .
+      .
+      CloseHandle(hDLL);
+    }   
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dilshan R Jayakody</dc:creator><pubDate>Sun, 17 Nov 2013 12:01:22 -0000</pubDate><guid>https://sourceforge.net49b2d0cf2f42b6881e00a131e5c2e8120875184b</guid></item><item><title>Example programs modified by Dilshan R Jayakody</title><link>https://sourceforge.net/p/microtone/wiki/Example%2520programs/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="example-programs"&gt;Example Programs&lt;/h1&gt;
&lt;p&gt;microTone Module example programs are located at &lt;em&gt;\samples&lt;/em&gt; directory. &lt;/p&gt;
&lt;h2 id="code-template"&gt;Code template&lt;/h2&gt;
&lt;p&gt;Recommended code layout for static DLL interface (this example use Lazarus):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c1"&gt;// 1. load functions from DLL.&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;UTMCreatePacket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;OutData&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Word&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;stdcall&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;external&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="n"&gt;utm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dll&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;UTMCreateBytePacket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;OutData:&lt;/span&gt; &lt;span class="n"&gt;Byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Word&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;stdcall&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;external&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="n"&gt;utm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dll&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="c1"&gt;// 2. Reset the device using 0x9 command.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;UTMCreatePacket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;then&lt;/span&gt;
&lt;span class="k"&gt;begin&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="c1"&gt;// 3. Send command to device.&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;UTMCreateBytePacket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;255&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0&lt;/span&gt; &lt;span class="n"&gt;then&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dilshan R Jayakody</dc:creator><pubDate>Sun, 17 Nov 2013 11:07:39 -0000</pubDate><guid>https://sourceforge.net41f22a6adc9b0fedbe4ca48c9f0c70e6dd6ff779</guid></item></channel></rss>