32-bit and 64-bit

How I can create a .net application with TurboActive for 32- and 64-bit system? I would like to create only one, universal application for all environments.

I've just looked for folders with TurboActive.dll and TurboActive.exe for x86 and x64.

I can detect 64-bit system (NET 4 has two new properties in the Environment class, Is64BitProcess and Is64BitOperatingSystem).

How I can load specified TurboActive.dll ?

You can do it a few ways. The following code assumes you're using C#, but the same concepts apply to VB.NET.

The easiest is to modify the TurboActivate.cs file like this:

    static class Native32    {        [DllImport("32bit\TurboActivate.dll", CharSet = CharSet.Unicode)]        public static extern int Activate();...    }

Notice the class name is now "Native32" and the DllImport points to "32bit\TurboActivate.dll". Now add a 64-bit version of the native functions:

    static class Native64    {        [DllImport("64bit\TurboActivate.dll", CharSet = CharSet.Unicode)]        public static extern int Activate();......    }

Now you have native functions that can call either the 32-bit or 64-bit versions of TurboActivate. Add TurboActivate files to the "64bit" and "32bit" folders relative to your app.

Lastly, you need to modify the functions to call either the 32-bit or 64-bit functions depending on whether the app is being run as a 32-bit process or 64-bit process.

For example,

    public static void Deactivate(bool eraseProductKey)    {        switch (Environment.Is64BitProcess ? Native64.Deactivate(eraseProductKey) : Native32.Deactivate(eraseProductKey))        {            case 2: // TA_E_PKEY                throw new InvalidProductKeyException();            case 4: // TA_E_INET                throw new InternetException();            case 8: // TA_E_PDETS                throw new ProductDetailsException();            case 11: // TA_E_COM                throw new COMException();            case 0: // successful                return;            default:                throw new GeneralTurboActivateException("Failed to deactivate.");        }    }

Does this help?