views:

152

answers:

1

There is magnification.lib in win7/vista SDK for using magnification API for C++ (http://msdn.microsoft.com/en-us/library/ms692162%28VS.85%29.aspx). How can I use this API in .NET windows forms project? Thank you for any advice.

+2  A: 

You need to use P/Invoke for this task. Have a look at the below C# code snippet:

[DllImport("Magnification.dll"]
static extern bool MagInitialize();
...
[DllImport("Magnification.dll"]
static extern bool MagUninitialize();

void Main()
{
    if (MagInitialize())
    {
        DoSomething();
    }
    ...
    MagUnitialize();
}

Here you declare all the methods you need to use in you WinForms app and then you call them just as if they were ordinary methods. You can find many useful information and samples on pinvoke.net web site. Please also note that you don't need Magnification.lib at all, it is the library for linking with an unmanaged C/С++ code.

Igor Korkhov