استفاده از تابع GetSystemInfo در VB.Net و فرق آن در VB6.0
با سلام
دوستان من با این کد در VB6.0 میتونم کار کنم و مقادیر lpMinimumApplicationAddress و lpMaximumApplicationAddress رو میگیرم
ولی همین کد در VB.Net کار نمیکنه
متن خطا در vb.net
نقل قول:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt
کد در vb.net
کد:
Public Class Form1
Private Structure SYSTEM_INFO
Dim dwOemID As Long
Dim dwPageSize As Long
Dim lpMinimumApplicationAddress As Long
Dim lpMaximumApplicationAddress As Long
Dim dwActiveProcessorMask As Long
Dim dwNumberOfProcessors As Long
Dim dwProcessorType As Long
Dim dwAllocationGranularity As Long
Dim wProcessorLevel As Integer
Dim wProcessorRevision As Integer
End Structure
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim SI As SYSTEM_INFO
Call GetSystemInfo(SI)
MsgBox(SI.lpMinimumApplicationAddress & " " & SI.lpMaximumApplicationAddress)
End Sub
End Class
همین کد در VB6.0 کار کار میکنه
کد:
Option Explicit
Private Type SYSTEM_INFO
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Sub Command1_Click()
Dim SI As SYSTEM_INFO
Call GetSystemInfo(SI)
MsgBox SI.lpMinimumApplicationAddress & " " & SI.lpMaximumApplicationAddress
End Sub