Skip to content

User32.DLL

Ahmad

Asked Feb 19, 2009, 11:03 AM EST1 answer
Share
LinkedInX

hi all

I hope to know how to use user32.dll in my C# windows Application and i will appreciate who uploaded user32.dll with thanx.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    Ok Ahmad,

    You  have to use COM interop because user32 is unmanaged code that means written outside the .Net language C, C++(not VC++) so we use the System.Runtime.InteropServices to import this unmanaged code

    First add the namespace System.Runtime.Interop

    Then to call any function within user32.dll library you have to do as follow

    [DllImport("user32.dll")]
    static extern <Method name>(Arg0, Arg1,........,ArgN);

    then to call it you simply invoke it within your code

    Example:

    To draw text using the method DrawText of user32.dll

    http://www.pinvoke.net/default.aspx/user32.DrawText
     
    0