<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Factory Automation Software Blog &#187; Windows Development</title>
	<atom:link href="http://factoryswblog.org/category/development-techniques/win-dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://factoryswblog.org</link>
	<description>Merging modern software development with electrons and metal</description>
	<lastBuildDate>Fri, 27 Jan 2012 03:14:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>My Fall Software Development Books</title>
		<link>http://factoryswblog.org/2011/09/12/my-fall-software-development-books/</link>
		<comments>http://factoryswblog.org/2011/09/12/my-fall-software-development-books/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 06:20:50 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Windows Development]]></category>
		<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Function Programming]]></category>
		<category><![CDATA[IronPython]]></category>
		<category><![CDATA[Statecharts]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://factoryswblog.org/?p=983</guid>
		<description><![CDATA[I just bought a lot of software development books, mostly centered on Microsoft&#8217;s .NET Framework.  I have a code base that is getting old and creaky (for example, parts are written in VB6) and it&#8217;s time to look at re-doing it, using Visual Studio 2010. I&#8217;m tempted to write everything in a mix of F# [...]]]></description>
			<content:encoded><![CDATA[<p>I just bought a lot of software development books, mostly centered on Microsoft&#8217;s .NET Framework.  I have a code base that is getting old and creaky (for example, parts are written in VB6) and it&#8217;s time to look at re-doing it, using Visual Studio 2010.</p>
<p>I&#8217;m tempted to write everything in a mix of F# and Boo, but I won&#8217;t, because it would be hard for almost anyone else to maintain it.  Instead, I&#8217;m planning on mostly C#, with maybe some IronPython thrown in (for rapid customization).</p>
<p>I&#8217;m reading each book quickly first to get an idea of what I can learn, then I will go back in depth for the techniques that I will use.</p>
<p>So what is on my list?</p>
<ul>
<li><a href="http://www.manning.com/skeet2/">C# In Depth, Second Edition</a> &#8212; to make sure I&#8217;m up to speed with all the latest changes to C#.  I haven&#8217;t read it yet.</li>
<li><a href="http://www.wrox.com/WileyCDA/WroxTitle/Functional-Programming-in-C-Classic-Programming-Techniques-for-Modern-Projects.productCd-0470970286.html">Functional Programming in C#</a> &#8212; highly recommended; it&#8217;s well written and shows how to use a lot of the functional techniques I&#8217;ve come to love from using Python; in short, it makes C# much more usable.  However, if you aren&#8217;t already familiar with concepts such as closures, first class functions, and lambdas, it&#8217;s going to be slow going for a while &#8212; and consider learning them in another language first (such as Lua using <a href="http://www.inf.puc-rio.br/~roberto/pil2/">Programming in Lua</a>).</li>
<li><a href="http://www.manning.com/osherove/">The Art of Unit Testing: With Examples in .NET</a> &#8212; highly recommended; it provides lots of practical advice and best practices for creating unit tests that work well.</li>
<li><a href="http://www.manning.com/foord/">IronPython In Action</a> &#8212; I haven&#8217;t read it yet, but it looks good, with a lot of best practices advice.</li>
<li><a href="http://www.state-machine.com/psicc/">Practical Statecharts in C/C++, First Edition</a> &#8212; I haven&#8217;t read it yet.  This book is really aimed at embedded developers, and although I don&#8217;t plan on using the author&#8217;s Quantum Programming framework, I think I will get some good ideas from it.</li>
</ul>
<p>The Manning books all include a free PDF of the book when you register your book.  I haven&#8217;t done this yet, but I will soon.</p>
<p>All my books are real, not e-books, because I prefer real books when learning a new topic, the paper books were cheaper or about the same price, and I won&#8217;t buy ebooks that require a proprietary reader (such as Kindle or Apple books).</p>
 <img src="http://factoryswblog.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=983" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://factoryswblog.org/2011/09/12/my-fall-software-development-books/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB6 Notes &#8211; Determining the calling convention of a C DLL</title>
		<link>http://factoryswblog.org/2007/10/25/vb6-notes-determining-the-calling-convention-of-a-c-dll/</link>
		<comments>http://factoryswblog.org/2007/10/25/vb6-notes-determining-the-calling-convention-of-a-c-dll/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 02:29:09 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Windows Development]]></category>
		<category><![CDATA[VB6]]></category>

		<guid isPermaLink="false">http://factoryswblog.org/2007/10/25/vb6-notes-determining-the-calling-convention-of-a-c-dll/</guid>
		<description><![CDATA[Some possible approaches for determining C calling conventions on Windows]]></description>
			<content:encoded><![CDATA[<p>OK, this isn&#8217;t just for VB6, but I needed to call a function in a C DLL from VB6, and VB6 can only call functions that use the stdcall calling convention.</p>
<p>A properly written C DLL is easy to use from VB6, but a C DLL not written with VB6 in mind may require an adapter layer.  C++ DLLs are typically very difficult to use from another compiler (or VB), due to incompatibilities in areas such as name mangling.  Of course, COM DLLs and .NET assembly DLLs are totally different cases.  COM objects are almost always easy to call from VB6.  .NET assemblies are like C DLL&#8217;s: when properly designed with a COM interop, using them is like using a COM object, but if they&#8217;re not designed with COM in mind, then they can&#8217;t be used.</p>
<p>If you have the source or header files, you should be able to determine the calling convention &#8211; although you may have to know a bit about the compiler, too (so you know what the default convention is, and how each convention is identified).</p>
<p>A second method that sometimes works is to use Microsoft&#8217;s dumpbin program.   You can get dumpbin for free by downloading and registering<a href="http://msdn2.microsoft.com/en-us/express/aa700735.aspx"> Visual C++ 2005 Express Edition</a> (<a href="http://www.codeproject.com/useritems/FreeVS2005Win32.asp">notes on Win32 development here</a>) .  By dumping the Export list and looking at the decorated names, you can determine the calling convention.  I got the idea for this approach from <a href="http://www.unixwiz.net/techtips/win32-callconv.html">here</a>.</p>
<p>For a function defined as <strong>void foo(int a)</strong>, its decorated name would be:</p>
<ul>
<li><strong>_foo</strong> for __cdecl (C calling convention)</li>
<li><strong>_foo@4</strong> for __stdcall (Windows calling convention)</li>
<li><strong>@foo@4</strong> for __fastcall</li>
</ul>
<p>I used <strong>dumpbin /EXPORTS path_to_dll</strong> from the Visual C++ 2005EE command prompt.  However, not all DLLs export the decorated names, even for DLLs created with MS VC++.  I&#8217;ve seen some that do and some that don&#8217;t; it might have to do with how the exported names are declared (e.g. in a DEF file).  Non-Microsoft C compilers (MingW, gcc, Borland, etc) might decorate names differently.</p>
<p>By the way, you can use <strong>dumpbin /DEPENDENTS path_to_DLL</strong> to see what DLLs a DLL requires.</p>
<p>Another way is to use <a href="http://www.python.org">Python </a>and the ctypes module.  The ctypes module is included in Python 2.5; it&#8217;s an add-on to earlier versions.   ctypes can load a DLL as either a Windows (stdcall) DLL using  windll.LoadLibrary or a C (cdecl) DLL using cdll.LoadLibrary.</p>
<p>Here&#8217;s an example using Python and two functions in the MEI PC/DSP 2.5.09 MEDVC60F.DLL.  One function (dsp_init) is stdcall; the other function (find_pci_dsp) is cdecl.</p>
<p>&gt;&gt;&gt; <strong>from ctypes import *</strong><br />
&gt;&gt;&gt; <strong>stdcall = windll.LoadLibrary(&#8216;C:\\medvc60f.dll&#8217;)</strong><br />
&gt;&gt;&gt; <strong>cdecl = cdll.LoadLibrary(&#8216;C:\\medvc60f.dll&#8217;)</strong><br />
&gt;&gt;&gt; <strong>ShortArray20Type = c_short * 20</strong><br />
&gt;&gt;&gt; <strong>addr = ShortArray20Type()</strong><br />
&gt;&gt;&gt; <strong>irq = ShortArray20Type()</strong><br />
&gt;&gt;&gt; <strong>numBoards = c_short(0)</strong><br />
&gt;&gt;&gt;<strong> cdecl.find_pci_dsp(byref(numBoards), byref(addr), byref(irq))</strong><br />
0<br />
&gt;&gt;&gt; <strong>stdcall.find_pci_dsp(byref(numBoards), byref(addr), byref(irq))</strong><br />
Traceback (most recent call last):<br />
File &#8220;&lt;interactive input&gt;&#8221;, line 1, in &lt;module&gt;<br />
ValueError: Procedure probably called with too many arguments (12 bytes in excess)<br />
&gt;&gt;&gt; <strong>cdecl.dsp_init(0&#215;300)</strong><br />
Traceback (most recent call last):<br />
File &#8220;&lt;interactive input&gt;&#8221;, line 1, in &lt;module&gt;<br />
ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention<br />
&gt;&gt;&gt; <strong>stdcall.dsp_init(0&#215;300)</strong><br />
2</p>
 <img src="http://factoryswblog.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=27" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://factoryswblog.org/2007/10/25/vb6-notes-determining-the-calling-convention-of-a-c-dll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

