试一下这个:This MBM 4 program gives API and makes custom displays bossible, it need the MBM4 program!Goto take the MBM 4 program
http://mbm.livewiredev.com/download4.htm
Start it and run the VB code , it do share certain memory areas, I hope you like the solution as it
is not all VB code the DLL in this MBM program does the job.first Download and install the MNM4 version and start it.
Form1.timer code for 10 textboxes, need to set timer interval ~1000 to ~2000
Private Sub Timer1_Timer()
Dim test As MBMDATA
test = GetMBMData
Text1 = test.Temp1Name
Text2 = test.Temp1
Text3 = test.Temp2Name
Text4 = test.Temp2
Text5 = test.Volt1
Text6 = test.Volt2
Text7 = test.Volt3
Text8 = test.Volt4
Text9 = test.Fan1Name
Text10 = test.Fan1
End Sub
This is the modulle fixed by two declares they give:
Option Explicit
'Function declares and constants needed
Public Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Public Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, _
ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, _
ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Public Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any,
ByVal Length As Long)
Public Const INVALID_HANDLE_VALUE = -1
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
Public Const SECTION_EXTEND_SIZE = &H10
Public Const SECTION_MAP_EXECUTE = &H8
Public Const SECTION_MAP_READ = &H4
Public Const SECTION_MAP_WRITE = &H2
Public Const SECTION_QUERY = &H1
Public Const SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SECTION_QUERY Or _
SECTION_MAP_WRITE Or SECTION_MAP_READ Or SECTION_MAP_EXECUTE Or SECTION_EXTEND_SIZE
Public Const FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS
Public Const FILE_MAP_COPY = SECTION_QUERY
Public Const FILE_MAP_READ = SECTION_MAP_READ
Public Const FILE_MAP_WRITE = SECTION_MAP_WRITE
'Data structure to hold data
Public Type MBMDATA
MBMVersion As String * 44
Temp1 As Double
Temp2 As Double
Temp3 As Double
Volt1 As Double
Volt2 As Double
Volt3 As Double
Volt4 As Double
Volt5 As Double
Volt6 As Double
Volt7 As Double
Fan1 As Long
Fan2 As Long
Fan3 As Long
Temp1Name As String * 14
Temp2Name As String * 14
Temp3Name As String * 14
Fan1Name As String * 14
Fan2Name As String * 14
Fan3Name As String * 14
Suspend As Long
End Type
'Sub to get data
Public Function GetMBMData() As MBMDATA
Dim lpData As Long
Dim hMap As Long
Dim dMBM As MBMDATA
hMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, 0, "$M$B$M$")
If hMap = INVALID_HANDLE_VALUE Then
'Can't get a handle to the shared data
Exit Function
Else
lpData = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0)
If lpData = 0 Then
'Can't map file
Exit Function
Else
CopyMemory dMBM, ByVal lpData, Len(dMBM)
End If
Call UnmapViewOfFile(lpData)
Call CloseHandle(hMap)
End If
GetMBMData = dMBM
'The shared data will now reside in the dMBM variable.
'You are now free to do what you like with the data.
'Call GetMBMData again to refresh the data. Maybe call it in a timer?
'Could be an idea to change the sub to a function and pass the data back
'or update a Public or Global variable.
End FunctionMatti
http://mbm.livewiredev.com/download4.htm
Start it and run the VB code , it do share certain memory areas, I hope you like the solution as it
is not all VB code the DLL in this MBM program does the job.first Download and install the MNM4 version and start it.
Form1.timer code for 10 textboxes, need to set timer interval ~1000 to ~2000
Private Sub Timer1_Timer()
Dim test As MBMDATA
test = GetMBMData
Text1 = test.Temp1Name
Text2 = test.Temp1
Text3 = test.Temp2Name
Text4 = test.Temp2
Text5 = test.Volt1
Text6 = test.Volt2
Text7 = test.Volt3
Text8 = test.Volt4
Text9 = test.Fan1Name
Text10 = test.Fan1
End Sub
This is the modulle fixed by two declares they give:
Option Explicit
'Function declares and constants needed
Public Declare Function OpenFileMapping Lib "kernel32" Alias "OpenFileMappingA" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
Public Declare Function MapViewOfFile Lib "kernel32" (ByVal hFileMappingObject As Long, _
ByVal dwDesiredAccess As Long, ByVal dwFileOffsetHigh As Long, _
ByVal dwFileOffsetLow As Long, ByVal dwNumberOfBytesToMap As Long) As Long
Public Declare Function UnmapViewOfFile Lib "kernel32" (lpBaseAddress As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any,
ByVal Length As Long)
Public Const INVALID_HANDLE_VALUE = -1
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
Public Const SECTION_EXTEND_SIZE = &H10
Public Const SECTION_MAP_EXECUTE = &H8
Public Const SECTION_MAP_READ = &H4
Public Const SECTION_MAP_WRITE = &H2
Public Const SECTION_QUERY = &H1
Public Const SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SECTION_QUERY Or _
SECTION_MAP_WRITE Or SECTION_MAP_READ Or SECTION_MAP_EXECUTE Or SECTION_EXTEND_SIZE
Public Const FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS
Public Const FILE_MAP_COPY = SECTION_QUERY
Public Const FILE_MAP_READ = SECTION_MAP_READ
Public Const FILE_MAP_WRITE = SECTION_MAP_WRITE
'Data structure to hold data
Public Type MBMDATA
MBMVersion As String * 44
Temp1 As Double
Temp2 As Double
Temp3 As Double
Volt1 As Double
Volt2 As Double
Volt3 As Double
Volt4 As Double
Volt5 As Double
Volt6 As Double
Volt7 As Double
Fan1 As Long
Fan2 As Long
Fan3 As Long
Temp1Name As String * 14
Temp2Name As String * 14
Temp3Name As String * 14
Fan1Name As String * 14
Fan2Name As String * 14
Fan3Name As String * 14
Suspend As Long
End Type
'Sub to get data
Public Function GetMBMData() As MBMDATA
Dim lpData As Long
Dim hMap As Long
Dim dMBM As MBMDATA
hMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, 0, "$M$B$M$")
If hMap = INVALID_HANDLE_VALUE Then
'Can't get a handle to the shared data
Exit Function
Else
lpData = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0)
If lpData = 0 Then
'Can't map file
Exit Function
Else
CopyMemory dMBM, ByVal lpData, Len(dMBM)
End If
Call UnmapViewOfFile(lpData)
Call CloseHandle(hMap)
End If
GetMBMData = dMBM
'The shared data will now reside in the dMBM variable.
'You are now free to do what you like with the data.
'Call GetMBMData again to refresh the data. Maybe call it in a timer?
'Could be an idea to change the sub to a function and pass the data back
'or update a Public or Global variable.
End FunctionMatti
解决方案 »
- 如何检测当前是否有模态窗体或对话框存在
- VB中运行时提示 实时错误 86 !!这是什么错误呀?
- 小弟用vb6.0在做海康威视的DS-4004HC卡,遇到一个问题,请教各位~
- 请问,报告的打印和预览
- 如何输入特殊字符
- 我在一个窗口添加信息,关闭此窗口,在其他窗口打开,不过不能显示刚加的信息,要能重新运行才能显示....在线
- VB做成EXE文件后为何在没装VB的机子提示错误,而有的又可以?
- 如何保留 Single 型数据的小数位数
- 我这申明API函数申明错了?
- 如何在过程中调用控件数组?
- 怎样将一个文件作为参数传递或返回
- Microsoft.Jet.OLEDB.3.51"与"Microsoft.Jet.OLEDB.4.0如何判断
也是应用mbm的
[email protected]