如何在C#中使用本机dll? [英] How to use native dlls in C#?

查看:198
本文介绍了如何在C#中使用本机dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在C#Windows Forms Visual Studio 2010中使用WinApi的所有dll.
我只想访问所有这些对象.
我需要一个很好的文档来学习如何在C#Windows窗体中使用dll,我更喜欢在msdn上阅读,但是我发现那里只是个垃圾.
对我来说很难,例如,我的下一个代码不起作用,让我们从下面的代码开始,如何简单地使其起作用?

I wanna know how can i use all of the dlls of WinApi in C# Windows Forms Visual Studio 2010.
I just wanna get access to all of them.
I need a good documentation to learn how to use dlls in C# Windows Forms, i prefer to read on msdn, but i found about it only kinda trash there.
It is pretty hard to me, for example, my next code doesn''t work, let''s start with this one, how simply to make it work?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;

namespace _123
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            Method();
        }

        [DllImport(@"Gdiplus.dll")]
        static extern void GdipWindingModeOutline(Matrix matrix, float f);

        private void Method()
        {
            GraphicsPath path = new GraphicsPath();
            GdipWindingModeOutline(new Matrix(), 5f);
        }
    }
}

推荐答案

您错过了一个参数, ^ ].
出于好奇,为什么要使用GDI+平面API?
You missed a parameter, according to the documentation[^].
Out of curiosity, why do you want to use the GDI+ flat API?


为什么? .NET拥有自己的一个非常好的图形类,在
Why? .NET has a perfectly good graphics class of its own, documented at http://msdn.microsoft.com/en-us/library/system.drawing.graphics%28v=vs.110%29.aspx[^]


我刚刚开始使用它,但是我使用了pinvoke加载项.

您可以在
http://www.pinvoke.net/ [
I''m just getting started with it, but I use the pinvoke add-in.

You can read about it at http://www.pinvoke.net/[^]

The add-in automatically adds signatures directly to your code.

My experience with it so far has been great.

Hope this helps!


这篇关于如何在C#中使用本机dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆