Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.25/5 (4 votes)
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?

C#
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);
        }
    }
}
Posted
Updated 15-Dec-14 6:12am
v2
Comments
BillWoodruff 15-Dec-14 21:40pm    
Having read your replies to the solutions here, I suggest that what you really want is to know how to use API calls in general when you reach the point in higher-level programming (as in using WinForms C#) and you absolutely need to use API calls because the available libraries do not provide what you must have.

There are a few thousand (?) API calls, of which you will seldom use any large number in a "real-world" application.

There is no point using Windows Forms if you are going to do everything with API calls.

You are confusing learning a skill ... how to use the API ... with owning an Encyclopedia of descriptions of skills.

You missed a parameter, according to the documentation[^].
Out of curiosity, why do you want to use the GDI+ flat API?
 
Share this answer
 
Comments
Ziya1995 15-Dec-14 12:52pm    
GraphicsPath, thank you, but it is not solution, look, here is WinAPI list:
http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx
I wanna be able to use all of them using Parameter Invoke or another way. So, what should i do? And i need msdn documentation of doing so, please help, thank you.
Sergey Alexandrovich Kryukov 16-Dec-14 1:21am    
This is silly...
—SA
Sergey Alexandrovich Kryukov 16-Dec-14 1:21am    
5ed.
—SA
CPallini 16-Dec-14 3:27am    
Thank you, Sergey.
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[^]
 
Share this answer
 
Comments
Ziya1995 15-Dec-14 12:59pm    
I used coding 2 years and i know all of that, i appreciate your help, but i need to be able to use all of the APIs of Windows API. For example, to choose some api and wrap it to use. How?
Richard MacCutchan 15-Dec-14 13:03pm    
Again, why? If you are writing .NET code then use the .NET classes which provide all the functionality of the Windows API. However if you really want to make life difficult for yourself, you can use Platform Invoke: see http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx and http://www.pinvoke.net/index.aspx
Ziya1995 15-Dec-14 13:12pm    
I have already read Platform Invoke Tutorial and first of all it is just a tutorial and second - it is outdated. I could not find real documentation of that in the whole msdn, that is why i am in trouble asking here this question. Second link is a program, thanks. So, i need a real msdn documentation like others i used reading. Thank you for attention. I wait for solution.
Richard MacCutchan 15-Dec-14 13:18pm    
Wait for a solution to what? I have given you all the information you need to use the Windows API from a C# program.
Ziya1995 15-Dec-14 13:24pm    
So there is not any documentation about that in exception of just Platform Invoke Tutorial? Because it is outdated and not clean written, i have read lots of documentations on msdn, it is poor written and outdated.
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!
 
Share this answer
 
https://social.msdn.microsoft.com/Forums/en-US/67917590-96b1-4eea-b35d-4b6bdc6cc2b3/how-to-find-corresponding-wrapper-methods-for-windows-apis?forum=winforms[^]

There isn't a way to use any Windows API just by importing a dll. Someone has to take the time to write that dll and that is a manual process. Most of the time, it is you who need to write such a dll to make things happen.

The API page you linked specifically said "Microsoft Product Support Services will not provide support for code that calls the flat API directly". You should write a wrapper DLL in C++ to use those C++ APIs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900