Building a Windows DLL for ODBC Applications [Part 1]

    By: Paul Vero on Jan 01, 2014

    This article shows how to create a re-usable DLL in which you can customize and build more functionality into it to suit your development and testing needs.

    I write lots of test code to debug and analyze customer issues related to the ASE connectivity drivers. The ASE ODBC Driver works with lots of custom and packaged applications and oftentimes we in Support receive step-by-step instructions and diagnos- tic logs, sometimes receiving a sample project to demonstrate the problem. During root cause analysis of the problem, I find it easiest to write an ODBC API application in C/C++ so I can debug the situation. The API code is further useful as a test case the Engineers add to their test suites to prevent a regression of the problem in future releases.

    As I write the test code, I find I create some useful functions. I used to keep the source to these functions in a text file and whenever I created a new test project, I’d just copy the source into my new project file. After awhile, I learned this was somewhat tedious and difficult to maintain the source code as I added functions. I decided to create a windows DLL (Dynamic Linked Library) to contain these functions and access them from test code whenever I wanted too. As I started to go down this road, I realized the task wasn’t as easy as I initially thought and I learned a great deal about some windows architecture and DLLs in general.

    I will share what I found out, from the perspective of someone who works with all sorts of programming languages and APIs, but not always at the depths of someone who codes exclusively. The objective here is to create a re-usable library in which you can build more functionality into it as you create more useful and available functions. I’ll write the article in sections, some will walk through the code and guide you so you can build your own library and some of it will be in the form of a specification when describing the functions. From this point, you can then go on your own, creating your own guide and specification in your own words, since the library will be your creation and you may find you need to share it amongst your colleagues.

    I will layout the concept of this DLL in four sections: Code Walk-Through, Functional Specification, Building the DLL in Visual Studio (using msdev 2005) and Creating a Test Application.

    Code Walk-through
    I want to start with a walk-through of the source code for the library, which I name odbcutil. As mentioned, I wrote this library as an aid in understanding customer issues, providing me the capability to hook up a debugger so I can explore the ASE ODBC Driver code via the API calls made in my test application. In addition to debugging the code, I wanted to print out details when errors and warnings occur so I can get an idea on what is happening.


    Login to read the article. Not a member? Create a free account!

    Released: January 1, 2014, 4:55 pm | Updated: March 5, 2014, 11:10 am
    Keywords: ASE Developer Article | Technical Journal | Development | ODBC | Paul Vero | Windows Development | Windows DLL




    Copyright © 2014 ISUG-TECH. All Rights Reserved
    All material, files, logos and trademarks within this site are copyright their respective organizations

    Terms of Service - Privacy Policy - Contact the Help Desk