[API]
FindWindowA
CreateFileMappingA
MapViewOfFile
UnmapViewOfFile
CloseHandle

[INCLUDE]
USLongAdd
PeekS_Wide

[DEFINE]
Public Enum QPPlayState
  QPState_Stopped = 0&
  QPState_Playing = 1&
  QPState_Paused = 2&
  End Enum

Private Enum QPOperationState
  QPState_Stopped = 0&
  QPState_Playing = 1&
  QPState_Paused = 2&
  QPState_Starting = 3&
  QPState_ApplyingSoundcard = 4&
  QPState_Quitting = 5&
  QPState_DeletingFiles = 6&
  QPState_ReadingFiles = 7&
  QPState_CrossOrFading = 8&
  End Enum

Public Enum QPMusicTypes
  QPMusicType_None = 0&
  QPMusicType_Tracker = 1&
  QPMusicType_Stream = 2&
  QPMusicType_CDAudio = 3&
  QPMusicType_InetStream = 4&
  End Enum

Public Type QPCurState
  FullFilename As String
  PlayState As QPPlayState
  OperationState As QPOperationState
  TypeOfMusic As QPMusicTypes
  SongLengthMS As Long
  SongLengthPatterns As Long
  End Type

Private Type xSPCopy
  xMode1 As Byte
  xMode2 As Byte
  xMusTP As Byte
  xResrd As Byte
  xLenAn As Long
  End Type

[CODE]
Public Function GetQuickPlayerState(xRes As QPCurState) As Boolean
  Dim hWndQP As Long
  Dim hMapFile As Long
  Dim lpMapAddress As Long
  Dim RetCode As Long
  Dim xChar1 As String
  Dim xType1 As xSPCopy
  Dim xLong1 As Long

  'Const PAGE_READWRITE = 4
  'Const FILE_MAP_ALL_ACCESS = &H1 Or &H2 Or &H4 Or &H8 Or &H10 Or &HF0000
  'Const WM_COMMAND = &H111&

  hWndQP = FindWindowA("QuickPlayer10046CustomClassMSG", "QuickPlayer")
  If Not hWndQP = 0& Then
    hMapFile = CreateFileMappingA(-1&, 0&, 4&, 0&, &H210&, "quickplayer_1234")
    If Not hMapFile = 0& Then
      lpMapAddress = MapViewOfFile(hMapFile, &HF001F, 0&, 0&, 0&)
      If Not lpMapAddress = 0& Then
        RetCode = SendMessageA(hWndQP, &H111&, 801&, ByVal 1234&)
        If RetCode > 0& And RetCode < &H200& Then
          With xRes
            .FullFilename = PeekS_Wide(lpMapAddress)
            xLong1 = lpMapAddress
            Call USLongAdd(xLong1, 2 * Len(.FullFilename) + 2&)
            Call RtlMoveMemory(xType1, ByVal xLong1, 8&)
            .OperationState = xType1.xMode1
            .PlayState = xType1.xMode2
            .TypeOfMusic = xType1.xMusTP
            If .TypeOfMusic = QPMusicType_Tracker Then
              .SongLengthPatterns = xType1.xLenAn
              Else
              .SongLengthMS = xType1.xLenAn
              End If
            End With
          GetQuickPlayerState = True
          End If
        Call UnmapViewOfFile(lpMapAddress)
        End If
      Call CloseHandle(hMapFile)
      End If
    End If
  End Function
