SHSTDAPI SHCreateItemFromParsingName(
PCWSTR pszPath,
IBindCtx *pbc,
REFIID riid,
void **ppv
);
I tried to map the above method to this method:
WinNT.HRESULT SHCreateItemFromParsingName(String pszPath, Pointer p, Guid.REFIID riid, PointerByReference ppv);
EDIT:
PointerByReference ppv = new PointerByReference();
Guid.REFIID rid = new Guid.REFIID(new Guid.IID(Shell32Extra.IID_IShellItem));
WinNT.HRESULT h = Shell32Extra.INSTANCE.SHCreateItemFromParsingName("*.txt",null,rid,ppv);
IShellItem shellItem = new IShellItem(ppv.getValue());
But the HRESULT throws failed with -2147024894
And if pbc is not null, it will throw an Memory access expection
What should I change? I think it maybe is failing because of the PCWSTR mapping.
While technomage points out mapping errors, these wouldn't be giving you the result you got. The HRESULT
of -2147024894 indicates the system can't find the file. Your dd.txt
file is not in the path that the program has access to.
Additionally you can use the WString
type to specify that you need a wide string. Wrap your dd.txt
(or longer path) in a WString
constructor and pass that.