This tutorial is an update to one I did years back for Visual C++ 6.0. That article has consistently been the most viewed page on icynorth.com by a long shot. I didn’t realize that until a year ago when I started using Google Analytics on the site, but it really surprised me to see. It goes to show that sometimes bringing things back to the basics can be a big hit.

This tutorial will teach you how to use Visual C++ 2005 (Visual Studio 2005 Professional) to create a small Win32 C++ DLL that can be called from C++, Visual Basic, Delphi, C# or any other program capable at calling DLL functions.

This DLL will have one purpose; to generate a unique filename using the Windows API function GetTempFileName. This function is useful if you need to store temporary data in a unique file for the user of your application and want to ensure that the file does not already exist. However, the point of this tutorial is not to generate unique filenames, but rather to show you how easy it is to create simple Windows DLLs using Visual C++.

The key here is “simple”. Windows DLLs are capable of much, much more than outlined here. This tutorial will only cover simple, Win32 DLL creation for those quick-and-dirty projects.

Continue Reading »