|
-
Jun 5th, 2018, 11:25 PM
#16
Fanatic Member
Re: VB6 MultiProcessing (StdExe-IPC via SharedMemory)
 Originally Posted by Schmidt
There is no need to apply a (non-unicode-capable) API for that.
I'd simply:
- define all Strings of a Shared-Memory-Area as fixed-length-string-members of an UDT
- then later always read (or write) the entire UDT-content from (or to) the Shared-Area via: UserDataWrite VarPtr(MyUDT), LenB(MyUDT)
- and for "InBetween" happening changes of the UDTs FixedLength-StringMembers I'd use a simple "Property-Helper" like shown below:
Code:
Option Explicit
Private Type tMyUDT
S As String * 100
End Type
Private Sub Form_Load()
Dim MyUDT As tMyUDT
Debug.Print Len(FLS(MyUDT.S)), FLS(MyUDT.S) 'print the S-member content from a fresh initialized UDT
FLS(MyUDT.S) = "123": Debug.Print Len(FLS(MyUDT.S)), FLS(MyUDT.S) 'print it after assigning "123"
FLS(MyUDT.S) = "": Debug.Print Len(FLS(MyUDT.S)), FLS(MyUDT.S) 'print it again, after assigning ""
End Sub
Private Property Let FLS(FLSmember As String, RHS As String)
If Len(FLSmember) <= Len(RHS) Then Err.Raise 7
FLSmember = RHS & vbNullChar
End Property
Private Property Get FLS(FLSmember As String) As String
Dim Pos As Long: Pos = InStr(FLSmember, vbNullChar)
If Pos > 0 Then FLS = Left$(FLSmember, Pos - 1)
End Property
Olaf
thanks .
I have a suggestion to add a length shared variable in the two class module. You can directly return the length
Private Type tShared 'a convenience-UDT, sitting at the top of the shared mem-area
UserDataLen As Long
MasterHwnd As Long
JobProgress As Single
JobPreparedHPSec As Double
JobStartedHPSec As Double
JobFinishedHPSec As Double
JobState As eJobState
UserWriteDataLen As Long '
End Type
Public Sub UserDataWrite(ByVal pSrc As Long, _
ByVal ByteLen As Long, _
Optional ByVal Offs As Long)
If BaseAddr Then
RtlMoveMemory ByVal UserDataPtr + Offs, ByVal pSrc, ByteLen
T.UserWriteDataLen = ByteLen
WriteInternalType T
End If
End Sub
I can know the length of the currently written data, and if it needs to be read, I can initialize the length of the variable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|