Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1460

As a Kinder Egg 3 in 1 Progress Dialogs Plus One Extra

$
0
0
I did find in MSDN that shell32 are using three (four) different progress interfaces (derived from the first one) for same things.
Here are they listed as code snippets

Code:

'<---From here is from Fafalone's mIID.bas module
Public Sub DEFINE_UUID(name As UUID, L As Long, w1 As Integer, w2 As Integer, B0 As Byte, b1 As Byte, b2 As Byte, B3 As Byte, b4 As Byte, b5 As Byte, b6 As Byte, b7 As Byte)
  With name
    .Data1 = L: .Data2 = w1: .Data3 = w2: .Data4(0) = B0: .Data4(1) = b1: .Data4(2) = b2: .Data4(3) = B3: .Data4(4) = b4: .Data4(5) = b5: .Data4(6) = b6: .Data4(7) = b7
  End With
End Sub

Public Function IID_IProgressDialog() As UUID
'{EBBC7C04-315E-11d2-B62F-006097DF5BD4}
Static IID As UUID
 If (IID.Data1 = 0&) Then Call DEFINE_UUID(IID, &HEBBC7C04, CInt(&H315E), CInt(&H11D2), &HB6, &H2F, &H0, &H60, &H97, &HDF, &H5B, &HD4)
IID_IProgressDialog = IID
End Function
'---> End here

Public Const sCLSID_ProgressDialog As String = "{F8383852-FCD3-11d1-A6B9-006097DF5BD4}"

Public Declare Function CoCreateInstance Lib "ole32.dll" (ByRef rclsid As Any, ByVal pUnkOuter As Long, ByVal dwClsContext As Long, riid As Any, ByRef ppv As Any) As Long
Public Declare Function GuidFromStringA Lib "shell32.dll" Alias "#703" (ByVal pszGUID As String, ByRef pguid As GUID) As Long
Public Declare Function GuidFromStringW Lib "shell32.dll" Alias "#704" (ByVal pszGUID As Long, ByRef pguid As GUID) As Long

Public Function ShCreateIProgressDialog(pIPD As IProgressDialog) As Long
  Static CLSID_ProgressDialog As GUID
  Dim hr As Long
 
  hr = GuidFromStringW(StrPtr(sCLSID_ProgressDialog), CLSID_ProgressDialog) '<-- This always returns success if you got correct A or W version
 
  hr = CoCreateInstance(CLSID_ProgressDialog, 0, CLSCTX_INPROC_SERVER, IID_IProgressDialog, pIPD)
 
  If hr = S_OK Then
    ShCreateIProgressDialog = S_OK
  Else
    ShCreateIProgressDialog = hr
  End If
 
End Function

Public Function ShCreateIOperationsProgressDialog(pIOPD As IOperationsProgressDialog) As Long
  Dim hr As Long
  Dim pIPD As IProgressDialog
 
  hr = ShCreateIProgressDialog(pIPD)
 
  If hr = S_OK Then
    Set pIOPD = pIPD
    ShCreateIOperationsProgressDialog = S_OK
  Else
    ShCreateIOperationsProgressDialog = hr
  End If
 
  Set pIPD = Nothing
End Function

Public Function ShCreateIActionProgressDialog(pIAPD As IActionProgressDialog) As Long
  Dim hr As Long
  Dim pIPD As IProgressDialog
 
  hr = ShCreateIProgressDialog(pIPD)
 
  If hr = S_OK Then
    Set pIAPD = pIPD
    ShCreateIActionProgressDialog = S_OK
  Else
    ShCreateIActionProgressDialog = hr
  End If
 
  Set pIPD = Nothing
End Function

Public Function ShCreateIActionProgress(pIAP As IActionProgress) As Long '**
  Dim hr As Long
  Dim pIPD As IProgressDialog
 
  hr = ShCreateIProgressDialog(pIPD)
 
  If hr = S_OK Then
    Set pIAP = pIPD
    ShCreateIActionProgress = S_OK
  Else
    ShCreateIActionProgress = hr
  End If
 
  Set pIPD = Nothing
End Function

** The fourth one is regarding to MSDN not implemented by applications.
https://learn.microsoft.com/en-us/wi...actionprogress

Viewing all articles
Browse latest Browse all 1460

Trending Articles