|
-
May 25th, 2024, 04:37 PM
#41
Fanatic Member
Re: How can I display the thumbnail of a video file in a Picturebox?
hey fafalone. tks for this. will give it a go.
Out of interest, would you have an example using oleexp.tlb as well. that way we have a choice. tks
-
May 25th, 2024, 04:40 PM
#42
Re: How can I display the thumbnail of a video file in a Picturebox?
Hi fafalone. Hmm, why PROPVARIANT and not the VB6 variant. I can't answer you directly. I know that I can also use the VB6 variant. I read PROPVARIANT in the MS documentation and automatically use a UDT for it without thinking about why. 
I have tB installed, but I don't have time to test it in detail. In VB.NET it is also easy to use COM interfaces. That's why there are some projects of mine in VB6 and VB.NET. Maybe someday for tB too.
-
May 25th, 2024, 08:50 PM
#43
Re: How can I display the thumbnail of a video file in a Picturebox?
 Originally Posted by k_zeon
hey fafalone. tks for this. will give it a go.
Out of interest, would you have an example using oleexp.tlb as well. that way we have a choice. tks
You'd do the same thing as the tB version minus the Currency->LongLong change, and check if the interface is nothing instead of Err.LastHResult. If you run into a specific question I'll help but I'm not doing 100% of the work to set up an oleexp.tlb project, take the original VB6 project, and change the calls to how they're done in the tB version. The .cls and .twin files in the repo can be viewed in browser, if you really don't want to download tB.
 Originally Posted by -Franky-
Hi fafalone. Hmm, why PROPVARIANT and not the VB6 variant. I can't answer you directly. I know that I can also use the VB6 variant. I read PROPVARIANT in the MS documentation and automatically use a UDT for it without thinking about why.
I have tB installed, but I don't have time to test it in detail. In VB.NET it is also easy to use COM interfaces. That's why there are some projects of mine in VB6 and VB.NET. Maybe someday for tB too.
Just asked because it seemed to add quite a bit of extra work. I'm a bit lazy.
With tB you can define interfaces right in the project like:
Code:
[InterfaceId("70AE66F2-C809-4E4F-8915-BDCB406B7993")]
[OleAutomation(False)]
Interface IMFSourceReader Extends stdole.IUnknown
Function GetStreamSelection(ByVal dwStreamIndex As Long) As Long
Sub SetStreamSelection(ByVal dwStreamIndex As Long, ByVal fSelected As BOOL)
Function GetNativeMediaType(ByVal dwStreamIndex As Long, ByVal dwMediaTypeIndex As Long) As IMFMediaType
Function GetCurrentMediaType(ByVal dwStreamIndex As Long) As IMFMediaType
Sub SetCurrentMediaType(ByVal dwStreamIndex As Long, ByVal pdwReserved As Long, ByVal pMediaType As IMFMediaType)
Sub SetCurrentPosition(ByRef guidTimeFormat As UUID, ByRef varPosition As Variant)
Function ReadSample(ByVal dwStreamIndex As Long, ByVal dwControlFlags As Long, ByRef pdwActualStreamIndex As Long, ByRef pdwStreamFlags As Long, ByRef pllTimestamp As LongLong) As IMFSample
Sub Flush(ByVal dwStreamIndex As Long)
Sub GetServiceForStream(ByVal dwStreamIndex As Long, ByRef guidService As UUID, ByRef riid As UUID, ByRef ppvObject As Any)
Function GetPresentationAttribute(ByVal dwStreamIndex As Long, ByRef guidAttribute As UUID) As Variant
End Interface
You could of course use dummies for ones you weren't going to call, just like Sub dummy1() to keep the vtable offsets the same.
-
May 26th, 2024, 02:20 AM
#44
Re: How can I display the thumbnail of a video file in a Picturebox?
 Originally Posted by fafalone
With tB you can define interfaces right in the project like:
Code:
[InterfaceId("70AE66F2-C809-4E4F-8915-BDCB406B7993")]
[OleAutomation(False)]
Interface IMFSourceReader Extends stdole.IUnknown
Function GetStreamSelection(ByVal dwStreamIndex As Long) As Long
Sub SetStreamSelection(ByVal dwStreamIndex As Long, ByVal fSelected As BOOL)
Function GetNativeMediaType(ByVal dwStreamIndex As Long, ByVal dwMediaTypeIndex As Long) As IMFMediaType
Function GetCurrentMediaType(ByVal dwStreamIndex As Long) As IMFMediaType
Sub SetCurrentMediaType(ByVal dwStreamIndex As Long, ByVal pdwReserved As Long, ByVal pMediaType As IMFMediaType)
Sub SetCurrentPosition(ByRef guidTimeFormat As UUID, ByRef varPosition As Variant)
Function ReadSample(ByVal dwStreamIndex As Long, ByVal dwControlFlags As Long, ByRef pdwActualStreamIndex As Long, ByRef pdwStreamFlags As Long, ByRef pllTimestamp As LongLong) As IMFSample
Sub Flush(ByVal dwStreamIndex As Long)
Sub GetServiceForStream(ByVal dwStreamIndex As Long, ByRef guidService As UUID, ByRef riid As UUID, ByRef ppvObject As Any)
Function GetPresentationAttribute(ByVal dwStreamIndex As Long, ByRef guidAttribute As UUID) As Variant
End Interface
You could of course use dummies for ones you weren't going to call, just like Sub dummy1() to keep the vtable offsets the same.
In VB.NET this is done almost the same as in tB.
Code:
<ComImport>
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
<Guid(IID_IPortableDeviceManager)>
Public Interface IPortableDeviceManager
<PreserveSig> Function GetDevices(<[In], Out, MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPWStr, SizeParamIndex:=1)> ByVal pPnPDeviceIDs As String(),
<[In], Out> ByRef pcPnPDeviceIDs As UInteger) As Integer
<PreserveSig> Function RefreshDeviceList() As Integer
<PreserveSig> Function GetDeviceFriendlyName(<[In], MarshalAs(UnmanagedType.LPWStr)> ByVal pszPnPDeviceID As String,
<[In], Out, MarshalAs(UnmanagedType.LPWStr)> ByVal pDeviceFriendlyName As StringBuilder,
<[In], Out> ByRef pcchDeviceFriendlyName As UInteger) As Integer
<PreserveSig> Function GetDeviceDescription(<[In], MarshalAs(UnmanagedType.LPWStr)> ByVal pszPnPDeviceID As String,
<[In], Out, MarshalAs(UnmanagedType.LPWStr)> ByVal pDeviceDescription As StringBuilder,
<[In], Out> ByRef pcchDeviceDescription As UInteger) As Integer
<PreserveSig> Function GetDeviceManufacturer(<[In], MarshalAs(UnmanagedType.LPWStr)> ByVal pszPnPDeviceID As String,
<[In], Out, MarshalAs(UnmanagedType.LPWStr)> ByVal pDeviceManufacturer As StringBuilder,
<[In], Out> ByRef pcchDeviceManufacturer As UInteger) As Integer
<PreserveSig> Function GetDeviceProperty(<[In], MarshalAs(UnmanagedType.LPWStr)> ByVal pszPnPDeviceID As String,
<[In], MarshalAs(UnmanagedType.LPWStr)> ByVal pszDevicePropertyName As String,
<[In], Out, MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.ByValArray, SizeParamIndex:=1)> ByVal pData As Byte(),
<[In], Out> ByRef pcbData As UInteger,
<[In], Out> ByRef pdwType As UInteger) As Integer
<PreserveSig> Function GetPrivateDevices(<[In], Out, MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPWStr, SizeParamIndex:=1)> ByVal pPnPDeviceIDs As String(),
<[In], Out> ByRef pcPnPDeviceIDs As UInteger) As Integer
End Interface
In some cases I also use a possibility in VB.NET that is similar to that of VB6 and DispCallFunc. I only use the pointer to the COM interface, the VTable and a delegate to call the function from a COM interface. Mostly when I only need a few functions from different COM interfaces.
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
|