K
K
KPIshnik2014-01-25 19:47:57
C++ / C#
KPIshnik, 2014-01-25 19:47:57

Create a Windows Explorer extension. How can I find out the parameters of a file?

I am creating an extension for Explorer. By right-clicking on a file/selected files and choosing my menu item, you need to write the file name, size and creation date of the file to the file. By what means can you find out these file parameters (the name must be without the full path)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2014-01-25
@KPIshnik

Implement the Initialize method of the IShellExtInit interface, get the path to the files in it:

HRESULT STDMETHODCALLTYPE XXX::Initialize(
        LPCITEMIDLIST pidlFolder,
        LPDATAOBJECT lpdobj,
        HKEY hkeyProgID)
{
        STGMEDIUM medium;
        FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};

        if(SUCCEEDED(lpdobj->GetData(&fe,&medium))) {
                UINT n = DragQueryFile((HDROP)medium.hGlobal,~0,NULL,0);
                for (UINT i = 0; i < n; ++i) {
                        char filePath[MAX_PATH];
                        DragQueryFile((HDROP)medium.hGlobal,i,filePath,MAX_PATH);
                        printf("%s\n", filePath);
                }
                ReleaseStgMedium(&medium);
        }
        return S_OK;
}

Open the file and call GetFileInformationByHandle, it will return you both the size and creation date. Will you cut off the last component from the path?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question