473,395 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Does anyone have an IPersistStream......


Does anyone have a VB.NET IPersistStream COM interface description I can
cadge please? If I remember rightly, you have to "flatten" inherited COM
interfaces (I think IPersistStream derives from IPersist or something).

Thanks,


Robin
Nov 21 '05 #1
3 3332

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:d0*******************@news.demon.co.uk...

Does anyone have a VB.NET IPersistStream COM interface description I can
cadge please? If I remember rightly, you have to "flatten" inherited COM
interfaces (I think IPersistStream derives from IPersist or something).

Thanks,


Robin


HTH!

Namespace QCDemoServerVB

<ComImport(), Guid("0000010c-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersist
Sub GetClassID(ByRef pClassId As Guid)
End Interface

<ComImport(), Guid("00000109-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersistStream : Inherits IPersist
Shadows Sub GetClassID(ByRef pClassId As Guid)
<PreserveSig()> _
Function IsDirty() As Integer
Sub Load(ByVal pStm As UCOMIStream)
Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)>
ByVal fClearDirty As Boolean)
Sub GetMaxSize(ByRef pCbSize As Long)
End Interface

<Serializable()> _
Public Class cMsg
Implements IPersistStream

Public mbRequiresSave As Boolean
Private strTimeEntry As String
'Private strMsg As String

Sub GetClassID1(ByRef pClassId As Guid) Implements
IPersist.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rver.cMsg"))
End Sub

Sub GetClassID(ByRef pClassId As Guid) Implements
IPersistStream.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rverVB.cMsg"))
End Sub

Function IsDirty() As Integer Implements IPersistStream.IsDirty
If mbRequiresSave Then
Return 0
Else
Return 1
End If
End Function

Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)>
ByVal fClearDirty As Boolean) Implements IPersistStream.Save

WriteLog("QCDemoServerVB:Save")
If pStm Is Nothing Then
Exit Sub
Else
Dim bf As Binary.BinaryFormatter = New
Binary.BinaryFormatter
Dim ms As IO.MemoryStream = New IO.MemoryStream
bf.Serialize(ms, pStm)
End If
If fClearDirty Then
fClearDirty = False
Else
fClearDirty = True
End If

End Sub

Sub Load(ByVal pStm As UCOMIStream) Implements IPersistStream.Load

Try
WriteLog("QCDemoServerVB:Load")
Dim memStream As IO.MemoryStream = New IO.MemoryStream
Dim binForm As Binary.BinaryFormatter = New
Binary.BinaryFormatter

'Dim sta As STATSTG
'Dim arr() As Byte
'pStm.Stat(sta, 1)
'im cb As Long = CType(, Integer)
'Dim pcbRead As IntPtr
'pStm.Read(arr, sta.cbSize, pcbRead)
Dim sizearr() As Byte =
Convert.FromBase64String(strTimeEntry)
'Dim pCbSize As Long = sizearr.Length

Dim myutf As UTF8Encoding = New UTF8Encoding
strTimeEntry = myutf.GetString(sizearr)

Catch ex As Exception
Dim sb As New Text.StringBuilder
With sb
.Append("Display Message failed: ")
.Append(ex.Message)
End With
EventLog.WriteEntry("Display Message", sb.ToString,
EventLogEntryType.Error)

' then re-raise the error
Throw ex
End Try

End Sub

Sub GetMaxSize(ByRef pCbSize As Long) Implements
IPersistStream.GetMaxSize
WriteLog("QCDemoServerVB:GetMaxSize")
Dim sizearr() As Byte = Convert.FromBase64String(strTimeEntry)
pCbSize = sizearr.Length
End Sub

Public Property TimeEntry() As String
Get
Return strTimeEntry
End Get
Set(ByVal Value As String)
strTimeEntry = Value
End Set
End Property

'Public Property MessageBody() As String
'Get
' Return strMsg
'End Get
'Set(ByVal Value As String)
' strMsg = Value
'End Set
'End Property

Private Sub WriteLog(ByVal str As String)
Dim w As StreamWriter = File.AppendText("C:\QCIPersist.txt")
Log(str, w)
' Close the writer and underlying file.
w.Close()
End Sub

Private Sub Log(ByVal logMessage As String, ByVal w As TextWriter)
w.Write(ControlChars.CrLf & "Log Entry : ")
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString())
w.WriteLine(" :")
w.WriteLine(" :{0}", logMessage)
w.WriteLine("-------------------------------")
' Update the underlying file.
w.Flush()
End Sub

End Class
End Namespace
Nov 21 '05 #2
Much appreciated, thanks.

"3l33t" <no****@spam.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:d0*******************@news.demon.co.uk...

Does anyone have a VB.NET IPersistStream COM interface description I can
cadge please? If I remember rightly, you have to "flatten" inherited COM
interfaces (I think IPersistStream derives from IPersist or something).

Thanks,


Robin


HTH!

Namespace QCDemoServerVB

<ComImport(), Guid("0000010c-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersist
Sub GetClassID(ByRef pClassId As Guid)
End Interface

<ComImport(), Guid("00000109-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersistStream : Inherits IPersist
Shadows Sub GetClassID(ByRef pClassId As Guid)
<PreserveSig()> _
Function IsDirty() As Integer
Sub Load(ByVal pStm As UCOMIStream)
Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)>
ByVal fClearDirty As Boolean)
Sub GetMaxSize(ByRef pCbSize As Long)
End Interface

<Serializable()> _
Public Class cMsg
Implements IPersistStream

Public mbRequiresSave As Boolean
Private strTimeEntry As String
'Private strMsg As String

Sub GetClassID1(ByRef pClassId As Guid) Implements
IPersist.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rver.cMsg"))
End Sub

Sub GetClassID(ByRef pClassId As Guid) Implements
IPersistStream.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rverVB.cMsg"))
End Sub

Function IsDirty() As Integer Implements IPersistStream.IsDirty
If mbRequiresSave Then
Return 0
Else
Return 1
End If
End Function

Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)>
ByVal fClearDirty As Boolean) Implements IPersistStream.Save

WriteLog("QCDemoServerVB:Save")
If pStm Is Nothing Then
Exit Sub
Else
Dim bf As Binary.BinaryFormatter = New
Binary.BinaryFormatter
Dim ms As IO.MemoryStream = New IO.MemoryStream
bf.Serialize(ms, pStm)
End If
If fClearDirty Then
fClearDirty = False
Else
fClearDirty = True
End If

End Sub

Sub Load(ByVal pStm As UCOMIStream) Implements IPersistStream.Load

Try
WriteLog("QCDemoServerVB:Load")
Dim memStream As IO.MemoryStream = New IO.MemoryStream
Dim binForm As Binary.BinaryFormatter = New
Binary.BinaryFormatter

'Dim sta As STATSTG
'Dim arr() As Byte
'pStm.Stat(sta, 1)
'im cb As Long = CType(, Integer)
'Dim pcbRead As IntPtr
'pStm.Read(arr, sta.cbSize, pcbRead)
Dim sizearr() As Byte =
Convert.FromBase64String(strTimeEntry)
'Dim pCbSize As Long = sizearr.Length

Dim myutf As UTF8Encoding = New UTF8Encoding
strTimeEntry = myutf.GetString(sizearr)

Catch ex As Exception
Dim sb As New Text.StringBuilder
With sb
.Append("Display Message failed: ")
.Append(ex.Message)
End With
EventLog.WriteEntry("Display Message", sb.ToString,
EventLogEntryType.Error)

' then re-raise the error
Throw ex
End Try

End Sub

Sub GetMaxSize(ByRef pCbSize As Long) Implements
IPersistStream.GetMaxSize
WriteLog("QCDemoServerVB:GetMaxSize")
Dim sizearr() As Byte = Convert.FromBase64String(strTimeEntry)
pCbSize = sizearr.Length
End Sub

Public Property TimeEntry() As String
Get
Return strTimeEntry
End Get
Set(ByVal Value As String)
strTimeEntry = Value
End Set
End Property

'Public Property MessageBody() As String
'Get
' Return strMsg
'End Get
'Set(ByVal Value As String)
' strMsg = Value
'End Set
'End Property

Private Sub WriteLog(ByVal str As String)
Dim w As StreamWriter = File.AppendText("C:\QCIPersist.txt")
Log(str, w)
' Close the writer and underlying file.
w.Close()
End Sub

Private Sub Log(ByVal logMessage As String, ByVal w As TextWriter)
w.Write(ControlChars.CrLf & "Log Entry : ")
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString())
w.WriteLine(" :")
w.WriteLine(" :{0}", logMessage)
w.WriteLine("-------------------------------")
' Update the underlying file.
w.Flush()
End Sub

End Class
End Namespace

Nov 21 '05 #3
np

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:d0*******************@news.demon.co.uk...
Much appreciated, thanks.

"3l33t" <no****@spam.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:d0*******************@news.demon.co.uk...

Does anyone have a VB.NET IPersistStream COM interface description I can cadge please? If I remember rightly, you have to "flatten" inherited COM interfaces (I think IPersistStream derives from IPersist or something).

Thanks,


Robin


HTH!

Namespace QCDemoServerVB

<ComImport(), Guid("0000010c-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersist
Sub GetClassID(ByRef pClassId As Guid)
End Interface

<ComImport(), Guid("00000109-0000-0000-C000-000000000046"), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )> _
Interface IPersistStream : Inherits IPersist
Shadows Sub GetClassID(ByRef pClassId As Guid)
<PreserveSig()> _
Function IsDirty() As Integer
Sub Load(ByVal pStm As UCOMIStream)
Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean)
Sub GetMaxSize(ByRef pCbSize As Long)
End Interface

<Serializable()> _
Public Class cMsg
Implements IPersistStream

Public mbRequiresSave As Boolean
Private strTimeEntry As String
'Private strMsg As String

Sub GetClassID1(ByRef pClassId As Guid) Implements
IPersist.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rver.cMsg"))
End Sub

Sub GetClassID(ByRef pClassId As Guid) Implements
IPersistStream.GetClassID
pClassId =
Marshal.GenerateGuidForType(Type.GetType("QCDemoSe rverVB.cMsg"))
End Sub

Function IsDirty() As Integer Implements IPersistStream.IsDirty
If mbRequiresSave Then
Return 0
Else
Return 1
End If
End Function

Sub Save(ByVal pStm As UCOMIStream, <MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) Implements IPersistStream.Save

WriteLog("QCDemoServerVB:Save")
If pStm Is Nothing Then
Exit Sub
Else
Dim bf As Binary.BinaryFormatter = New
Binary.BinaryFormatter
Dim ms As IO.MemoryStream = New IO.MemoryStream
bf.Serialize(ms, pStm)
End If
If fClearDirty Then
fClearDirty = False
Else
fClearDirty = True
End If

End Sub

Sub Load(ByVal pStm As UCOMIStream) Implements IPersistStream.Load
Try
WriteLog("QCDemoServerVB:Load")
Dim memStream As IO.MemoryStream = New IO.MemoryStream
Dim binForm As Binary.BinaryFormatter = New
Binary.BinaryFormatter

'Dim sta As STATSTG
'Dim arr() As Byte
'pStm.Stat(sta, 1)
'im cb As Long = CType(, Integer)
'Dim pcbRead As IntPtr
'pStm.Read(arr, sta.cbSize, pcbRead)
Dim sizearr() As Byte =
Convert.FromBase64String(strTimeEntry)
'Dim pCbSize As Long = sizearr.Length

Dim myutf As UTF8Encoding = New UTF8Encoding
strTimeEntry = myutf.GetString(sizearr)

Catch ex As Exception
Dim sb As New Text.StringBuilder
With sb
.Append("Display Message failed: ")
.Append(ex.Message)
End With
EventLog.WriteEntry("Display Message", sb.ToString,
EventLogEntryType.Error)

' then re-raise the error
Throw ex
End Try

End Sub

Sub GetMaxSize(ByRef pCbSize As Long) Implements
IPersistStream.GetMaxSize
WriteLog("QCDemoServerVB:GetMaxSize")
Dim sizearr() As Byte = Convert.FromBase64String(strTimeEntry) pCbSize = sizearr.Length
End Sub

Public Property TimeEntry() As String
Get
Return strTimeEntry
End Get
Set(ByVal Value As String)
strTimeEntry = Value
End Set
End Property

'Public Property MessageBody() As String
'Get
' Return strMsg
'End Get
'Set(ByVal Value As String)
' strMsg = Value
'End Set
'End Property

Private Sub WriteLog(ByVal str As String)
Dim w As StreamWriter = File.AppendText("C:\QCIPersist.txt")
Log(str, w)
' Close the writer and underlying file.
w.Close()
End Sub

Private Sub Log(ByVal logMessage As String, ByVal w As TextWriter) w.Write(ControlChars.CrLf & "Log Entry : ")
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString())
w.WriteLine(" :")
w.WriteLine(" :{0}", logMessage)
w.WriteLine("-------------------------------")
' Update the underlying file.
w.Flush()
End Sub

End Class
End Namespace


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: lawrence | last post by:
Suppose I create dynamic web pages with 3 functions (which call other functions to make everything happen, but these 3 you might think of as being the top layer): registerSessions();...
1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
2
by: reycri | last post by:
I have a .Net class (a collection) that already supports serialization. It implements ISerializable... Now, I need it to also support the COM interface IPersistStream. Among other things, I need...
1
by: J Askey | last post by:
Is this object available in Access? If so, what do I need to set a reference to? My bigger picture is needing a way to take a .bmp out of a SQL database and put into both an CommandBarButton...
2
by: Brent Taylor via AccessMonster.com | last post by:
HELP----DOES ANYONE HAVE A SIMPLE .mdb for MLM structure? Does anyone have an example database for multi-level marketing for a 3 Tier setup? Thank you, brenttaylor@actionimports.net
6
by: Benjamin Day | last post by:
Does anyone ACTUALLY have the application updater block working? I've been beating my head against the wall on this one for about 3 days. It looks cool. It seems promising. I've even read this...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
3
by: Mephistopheles | last post by:
>>"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message >>news >>:%23N6vQmpSFHA.3184@TK2MSFTNGP14.phx.gbl... >> Hi, >> I have a function already but I need to solve one...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.