Wednesday, 27 June 2012

Creating a custom ACT database/Shim



If you have an application that was designed for early versions of Windows and you are having problems with the application on Windows 7 you may be able to resolve the issues by running the application in compatibility mode.

You can automate the install and enable the application to run in the chosen mode for all users by creating a custom compatibility database for the exe of the application.

The application I have uses a Paradox database file that is stored in the root of the C: drive (PDOXUSRS.NET) which although can be given the appropriate user rights for all users read/write access requires that the application exe is run in Windows XP compatibility mode.

Download the Application Compatibility Toolkit from Microsoft:


Install the Application Compatibility Toolkit on your test machine along with your problem application.
Start the Compatibility Administrator.












This should launch with a Custom Database ready for you to modify, if the screen does not appear as shown above simply click the `New` button to create a new custom database.

Rename the database to match your application, include a version number so that the new database matches your application version and you will not get confused if you have to repeat this process for other applications.












Click the `Fix` button and enter the required details for the application.

















Click Next to continue

Select the Compatibility mode required for the application and if you require additional modes, and click Next















Accept the compatibility fixes selected and click Next.

















Confirm the matching information and click Finish













Save the Database (sdb) file to a safe location giving it the appropriate names of the application this will fix.















The application can now be tested on a clean machine by running the following command with administrative rights after the application has been installed:

Sdbinst Birchfield_NutrientAnalyser_1.0.sbd

If this has been successful you should be able to run your application under a standard user account.


Friday, 6 January 2012

Its a new year...

Just a quick post to show that I am still alive, I have been very busy over the last few months so haven't posted anything new but I will get something together over the next few weeks.

I have a new toy that is responsible for my lack of posts: http://uksn2001.blogspot.com/

:)

Wednesday, 24 August 2011

Find registry Product code using C#

If you need to query details of the windows registry to find an installed MSI this little method will enable you to work out the Hive that the product details are installed under, assuming you know the Product Code of the MSI. This just saves enumerating through all of the registry keys.

Look in the following registry hive:
HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-x-x-xx\Products
You should now see a load of GUID's which are all modified Product Codes, here is how you work out the GUID.

The returned String will be the same as the Keys in the registry.
I don't know if this is useful to anyone or not and I haven't needed this code for a long time, but a previous organization needed the registry GUID in thier documentation so I put together this simple method so that I could find the details without searching the registry.

Query an MSI database from C#

Some simple code to enable querying an MSI database from C#

A simple connection method that returns a True or False depending on the success of connecting, the Filename is retrieved from an input box on the main form called "txtSource" and sets the global variable msiDatabase.
You will need to add the reference to "Microsoft Windows Installer Object Library" or "C:\Windows\System32\MSI.dll"



And here is a simple SQL query to pull out a value from the property table.

The same code can be used in a windows form application or you could create a simple command line utility to return a property value.

Monday, 22 August 2011

Wavefront.obj Parser

When I started investigating the Wavefront.obj format I was really unsure of where I was going and how I was going to use the file format but after a little searching I came across the following link that looked of some interest, Spark3d project The project appears pretty old and dose not look as if anything has happened to it in a long while, this was ok for me as I was actually only interested in the file parser, or how to parse a file.

The code that I am using is very similar to the original Spark3d parser, however it has been re-written by me so that I can understand what is going on and there are a few tweaks that I have added and quite a bit that I have removed, I don't need anything complicated and to be honest at my level of C# I simply don't understand some of the code, so if I dont understand it, remove it :)

Here is an example of the wavefront.obj file format and its the first one I started working with. This is a simple wireframe cube with no textures (there are no vt entries in the file).
You can copy and paste the contents into notepad.



If you look closely at the file you will notice that there are some spaces ' ' after some of the 'f' entries, the first one is 'f 1 2 3 4 '. The extra space has been added to the lines so that the code can handle the space, my first version worked fine without the space but fell over with an out-of-bounds, If this code was being used for anything other than a simple learning tool I would improve the stability and add some error trappings for such issues.

So the Basic parser will do 2 simple things.
  • It will read all the v entries into a list.
  • It will create a list based on the correct v entries as read from the file f entries!

    So as an example
    f 8 7 6 5

    Is Actually:

    2.000000 2.000000 0.000000
    2.000000 0.000000 0.000000
    0.000000 0.000000 0.000000
    0.000000 2.000000 0.000000


    The file will actually build a list of 24 vector3d's into an array which we will draw, There are '# 6 elements' each with 4 entries making a total of 24. I also have a file of a pitcher that I am working with that contains just short of 30,000 lines of entries (vertices and face definitions) which generates almost 60,000 vectors3d's when processed and actually works through this parser!!! (yep I was surprised too)

    So down to Business, the ObjParser.cs Class and its supporting Polygon.cs Class.





    The loadObjects() method is a pretty simple call to the class passing in the relevant file, firstly setting up the required variables.





    That's a simple object loaded from a file and displayed in the glControl1 control on the main form, nice and simple. I have tested this with a few wavefront.obj files downloaded from various sources around the web and it appears to be working without any issues, but its only doing the vertices. I will be working on textures next.

  • Drawing an Array

    So far the OpenGL code has been drawing a simple cube and adding a texture which is very easy to do within the code structure by including all the required vertices required within a simple DrawCube() method, whilst this is ok for simple objects its never going to work when we want to start drawing larger objects or even progressing onto using wavefront.obj files to import complex 3d structures.

    As a first step before I start with a object Parser capable of importing .obj files here are some simple changes which will allow us to draw an array.

    Define the array and populate the verticies.



    The render() method needs some simple changes to allow us to draw an array.



    That is really all there is to drawing an array. What this does now open up is the ability to create an Array for a much larger object maybe from loading one of those wavefront.obj files.....

    Wednesday, 17 August 2011

    Keyboard control...

    A very simple change to add simple keyboard control to the rotation of our cube.

    Create 2 global float variables


    and add these to the render() method

    Now create the gl1Control_KeyDown method with the following syntax.



    Finally add the "glControl1_KeyDown" method as the Key down event for the gl1control.


    Simple, now we can rotate the cube to see our textures.

    I think it was probably Pssst that got me really hooked on those keyboard controls :)