Basic Univers
; Tested on Windows XP Pro SP1

Procedure Ansi2Uni(st$)
  blen =(Len(st$)*2)+ 2
  wbuf = AllocateMemory(blen)
  MultiByteToWideChar_(#CP_ACP, 0, st$, - 1, wbuf, blen)
  ProcedureReturn wbuf
EndProcedure

#CLSCTX_INPROC_SERVER = 1

#PROGDLG_NORMAL = 0
#PROGDLG_AUTOTIME = 2

#PDTIMER_RESET = 1

#IDA_COPY_ANIMATION = 160 ; AVI file resource ID (I use an arbitrary constant name)
                          ; This one is from shell32.dll.
                          ; You can use any AVI file resource as long as it's
                          ; uncompressed or RLE8 compressed, silent and
                          ; smaller or equal to 272 by 60 pixels in size.

CoInitialize_(0)
hr = CoCreateInstance_(?CLSID_ProgressDialog, #Null, #CLSCTX_INPROC_SERVER, ?IID_IProgressDialog, @ppv.IProgressDialog)
If hr =#S_OK
  *Title = Ansi2Uni("System progress dialog box")
  ppv\SetTitle(*Title)
  hShell = OpenLibrary(0, "shell32.dll")
  If hShell
    ppv\SetAnimation(hShell, #IDA_COPY_ANIMATION)
  EndIf
  *Cancel = Ansi2Uni("Cancel")
  ppv\SetCancelMsg(*Cancel, 0)
  *Line1 = Ansi2Uni("System progress dialog test in PureBasic")
  ppv\SetLine(1, *Line1, #True, 0)
  ppv\StartProgressDialog(#Null, 0, #PROGDLG_AUTOTIME|#PROGDLG_NORMAL, 0)
  ppv\Timer(#PDTIMER_RESET, 0)
  Repeat
    If ppv\HasUserCancelled()
      MessageRequester("Messsage", "Progress cancelled")
      Break
    Else
      ppv\SetProgress(dwCompleted, 100)
      If dwCompleted>= 100
        MessageRequester("Messsage", "Progress completed")
        Break
      Else
        dwCompleted + 1
        *Line2 = Ansi2Uni("We are at progress point number " + Str(dwCompleted))
        ppv\SetLine(2, *Line2, #True, 0)
        FreeMemory(*Line2)
      EndIf
    EndIf
    Delay(100)
  ForEver
  ppv\StopProgressDialog()
  ppv\Release()
  FreeMemory(*Title)
  FreeMemory(*Cancel)
  FreeMemory(*Line1)
  If hShell: CloseLibrary(0): EndIf
Else
  Debug Hex(hr)
EndIf
CoUninitialize_()

DataSection
CLSID_ProgressDialog:
Data.l $F8383852
Data.w $FCD3, $11D1
Data.b $A6, $B9, 0, $60, $97, $DF, $5B, $D4
IID_IProgressDialog:
Data.l $EBBC7C04
Data.w $315E, $11D2
Data.b $B6, $2F, 0, $60, $97, $DF, $5B, $D4
EndDataSection