本文介绍了访问Microsoft.Win32.UnsafeNativeMethods?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

微软有包括.NET Framework中一个非常漂亮的Windows API的包装。它存储在 Microsoft.Win32.UnsafeNativeMethods Microsoft.Win32.SafeNativeMethods Microsoft.Win32.NativeMethods 。不幸的是,他们不是因为访问它们被声明为private。有轻松访问他们的一种方式?

Microsoft has a very nice Windows API wrapper included in .NET framework. It is stored in Microsoft.Win32.UnsafeNativeMethods , Microsoft.Win32.SafeNativeMethods and Microsoft.Win32.NativeMethods.Unfortunately they aren't accessible because they are declared as private. Is there a way of accessing them easily?

推荐答案

在这些类中的大多数方法的定义(如果不是全部) EXTERN 使用通过的P / Invoke指的是函数的Windows API中的属性。在不要紧,这些声明驻留。你可以创建自己的类名为UnsafeNativeMethods或SafeNativeMethods并把声明指相同的Windows API函数在那里。你会发现在为C#很多Windows API函数的签名。

Most method definitions in those classes (if not all) are extern declarations with DllImport attributes that refer to functions in the Windows API through P/Invoke. In doesn't matter where these declarations reside. You can create your own class named UnsafeNativeMethods or SafeNativeMethods and put declarations referring to the same Windows API functions in there. You'll find the signatures of many Windows API functions for C# on pinvoke.net.

这篇关于访问Microsoft.Win32.UnsafeNativeMethods?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:59