met*_*hod 4 c# pinvoke system.reflection methodbase
反正有没有检查方法是否使用PInvoke?我正在使用MethodBase循环遍历程序集中的所有方法,但我想检查该方法是否使用PInvoke.这是我正在使用的代码:
foreach (MethodBase bases in mtd.GetType().GetMethods())
{
//check if the method is using pinvoke
}
Run Code Online (Sandbox Code Playgroud)
另外,如果有可能,我怎么能检查正在使用的DLL和被调用的函数/入口点?
您可以检查方法是否使用DllImportAttribute进行修饰.如果是这样,那就是使用PInvoke.
foreach (MethodBase methodBase in mtd.GetType().GetMethods())
{
if (methodBase.CustomAttributes.Any(cad => cad.AttributeType == typeof(DllImportAttribute))
{
// Method is using PInvoke
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
176 次 |
| 最近记录: |