It looks like the definition of LPVOID is incorrect.  From WinDef.h, the definition is

    typedef void *LPVOID;

Which means it should be of JNA type `PointerType` and not derived from `LONG_PTR`.

On May 25, 2014, at 4:02 AM, Martin Steiger <notifications@github.com> wrote:

> In contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java:
> 
> > @@ -127,4 +131,16 @@ public void testResizeDesktopFromTop() throws InterruptedException {
> >  
> >      }
> >  
> > +    public void testSHGetKnownFolderPath()
> > +    {
> > +        int flags = ShlObj.KNOWN_FOLDER_FLAG.NONE.getFlag();
> > +        PointerByReference outPath = new PointerByReference();
> > +        HANDLE token = null;
> > +        GUID guid = KnownFolders.FOLDERID_Fonts;
> > +        HRESULT hr = Shell32.INSTANCE.SHGetKnownFolderPath(guid, flags, token, outPath);
> > +
> > +        Ole32.INSTANCE.CoTaskMemFree(new LPVOID(outPath.getPointer().getLong(0)));
> 
> About testing: Unfortunately, most folder names depend on the language. Also, many of them can be changed by the user (e.g. home folder), so we might have to rely on the HRESULT return value. I assumed that the focus of the testing should be on the correctness of the JNA mapping, not the actual Win32 API methods.
> 
> CoTaskMemFree: It also works with a plain Pointer. Would it make sense to convert the allocation method parameters from LPVOID to Pointer, too? It would be more consistent I guess..
> 
> —
> Reply to this email directly or view it on GitHub.
>