Friday, July 06, 2007

Incompatible API

My ex-colleague contacted me about my first project. The client had a problem when their customer tried to run the program in Windows 2000. It went fine on XP and above, but failed to run on 2000. I ran some code analysis and i made a preliminary hypothesis that it was caused by the code that prevent the application to be executed more than once. We used quite complicated Mutex class combined with some Windows API in order to prevent the application is being executed twice. It did work, but i haven't test the code in Windows 2000 after the implementation phase and now it became a problem. I suspect that there has been a non backward-compatibility on Windows API, mostly for kernel.dll which was being used.

So i tried to remove the code which deals with the Mutex and send it again to my coleague, since i don't have a direct access to the repository. I also don't have the development environment needed to test the program, so i edit the file directly via a text editor and modify it and sending it without compiling it (luckily i made some documentation on the code, so i know which part should be removed so easy). There were some errors (due to missing "}") but it was a simple task to do and finally it worked. So my hypothesis was correct. So i start looking for an alternative and i found a good one on CodeProject. Since the program was being build using C#, i tried to find the similar project and finally i found this article. The usage of this code is very simple and all you have to do is include the file in the project, add a new line in the declarative (using xxxxxx;) and then add some condition in the code which will start the main program and you are done with it. The code works on Windows 2000 also (even though it also uses the Windows API, but i guess it has better compatibility).

No comments:

Post a Comment