File: MediaInfoShellExt_.cpp

package info (click to toggle)
libmediainfo 0.7.70-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,220 kB
  • ctags: 16,696
  • sloc: cpp: 157,850; ansic: 4,082; xml: 1,264; cs: 944; java: 719; python: 565; sh: 345; makefile: 260; pascal: 195
file content (64 lines) | stat: -rwxr-xr-x 2,009 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// MediaInfoShellExt_.cpp : Implementation of CMediaInfoShellExt_

#include "stdafx.h"
#include "MediaInfoShellExt_.h"
#include <MediaInfoDLL/MediaInfoDLL_Static.h>


// CMediaInfoShellExt_

HRESULT CMediaInfoShellExt_::Load (LPCOLESTR wszFilename, DWORD)
{
    //Save FileName
    FileName = wszFilename;

    //OK
    return S_OK;
}

HRESULT CMediaInfoShellExt_::GetInfoTip (DWORD, LPWSTR* ppwszTip)
{
    LPMALLOC        Malloc;
    std::wstring    ToolTip;

    //Get an IMalloc interface from the shell.
    if (FAILED(SHGetMalloc(&Malloc)))
        return E_FAIL;

    //Creating tooltip
    ToolTip=_T("MediaInfo:\n");
    MediaInfoDLL::MediaInfo I;
    I.Option(_T("Inform"), _T("Summary"));
    I.Open(FileName);
    for (size_t StreamKind=0; StreamKind<(size_t)MediaInfoDLL::Stream_Max; StreamKind++)
        for (size_t StreamPos=0; StreamPos<I.Count_Get((MediaInfoDLL::stream_t)StreamKind); StreamPos++)
        {
            if (StreamKind>0)
            {
                ToolTip+=I.Get((MediaInfoDLL::stream_t)StreamKind, StreamPos, _T("StreamKind"));
                ToolTip+=_T(": ");
            }
            ToolTip+=I.Get((MediaInfoDLL::stream_t)StreamKind, StreamPos, _T("Inform"));
            ToolTip+=_T("\r\n");
        }
    if (ToolTip.size()>2)
        ToolTip.resize(ToolTip.size()-2); //Removing the ending \r\n

    //Allocate a buffer for Explorer.  Note that the must pass the string
    //back as a Unicode string, so the string length is multiplied by the
    //size of a Unicode character.
    *ppwszTip=(LPWSTR)Malloc->Alloc((ToolTip.size()+1)*sizeof(wchar_t));

    //Release the IMalloc interface now that we're done using it.
    Malloc->Release();

    //Enough memory?
    if (*ppwszTip==NULL)
        return E_OUTOFMEMORY;

    //Use the Unicode string copy function to put the tooltip text in the buffer.
    wcscpy_s(*ppwszTip, ToolTip.size()+1, T2COLE(ToolTip.c_str()));

    //OK
    return S_OK;
}