Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net ';System.Runtime.InteropServices.DllImportAttribute';无法应用于实例方法_Vb.net - Fatal编程技术网

Vb.net ';System.Runtime.InteropServices.DllImportAttribute';无法应用于实例方法

Vb.net ';System.Runtime.InteropServices.DllImportAttribute';无法应用于实例方法,vb.net,Vb.net,我正在尝试使用一些winapi方法。然而,当我尝试使用该函数时,出现以下错误: “System.Runtime.InteropServices.DllImportAttribute”不能应用于实例方法。 代码: 公共类反 _ 作为布尔值的公共函数ReadProcessMemory(ByVal hProcess作为IntPtr,ByVal LPbaseAddress作为Integer,ByRef lpBuffer作为Integer,ByVal nSize作为Integer,可选ByRef lpNu

我正在尝试使用一些winapi方法。然而,当我尝试使用该函数时,出现以下错误:

“System.Runtime.InteropServices.DllImportAttribute”不能应用于实例方法。 代码:

公共类反
_
作为布尔值的公共函数ReadProcessMemory(ByVal hProcess作为IntPtr,ByVal LPbaseAddress作为Integer,ByRef lpBuffer作为Integer,ByVal nSize作为Integer,可选ByRef lpNumberOfBytesRead作为Integer=0)
端函数
_
公共次零内存(ByVal句柄为IntPtr,ByVal长度为UInt32)
端接头
_
公共函数VirtualProtect(ByVal lpAddress作为IntPtr,ByVal dwSize作为Integer,ByVal flNewProtect作为Integer,ByRef lpflOldProtect作为UInteger)作为布尔值
端函数
公共次级反倾销()
尝试
尺寸x(0)As工艺

嗯,这个信息非常清楚。应用
DllImport
属性的方法必须是类方法(
shared

共享函数…
如果您想让代码分析愉快,请将类名更改为
NativeMethods
Public Class Anti
        <DllImport("kernel32.dll", SetLastError:=True)> _
    Public Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAdress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, Optional ByRef lpNumberOfBytesRead As Integer = 0) As Boolean
    End Function
    <DllImport("kernel32.dll", SetLastError:=True)> _
    Public Sub ZeroMemory(ByVal handle As IntPtr, ByVal length As UInt32)
    End Sub
    <DllImport("kernel32.dll", SetLastError:=True)> _
    Public Function VirtualProtect(ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flNewProtect As Integer, ByRef lpflOldProtect As UInteger) As Boolean
    End Function
    Public Sub AntiDump()
      Try
      Dim x(0) As Process