private SHCreateItemFromParsingName ( [ pszPath, IBindCtx pbc, [ riid, [ ppv ) : Standard.HRESULT | ||
pszPath | [ | |
pbc | IBindCtx | |
riid | [ | |
ppv | [ | |
Résultat | Standard.HRESULT |
public static IShellItem2 GetShellItemForPath(string path) { object obj; if (string.IsNullOrEmpty(path)) { return(null); } Guid guid = new Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93"); HRESULT sOK = NativeMethods.SHCreateItemFromParsingName(path, null, ref guid, out obj); if (sOK == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || sOK == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND) { sOK = HRESULT.S_OK; obj = null; } sOK.ThrowIfFailed(); return((IShellItem2)obj); }
public static IShellItem2 GetShellItemForPath(string path) { if (string.IsNullOrEmpty(path)) { // Internal function. Should have verified this before calling if we cared. return(null); } Guid iidShellItem2 = new Guid(IID.ShellItem2); object unk; HRESULT hr = NativeMethods.SHCreateItemFromParsingName(path, null, ref iidShellItem2, out unk); // Silently absorb errors such as ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND. // Let others pass through if (hr == (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND || hr == (HRESULT)Win32Error.ERROR_PATH_NOT_FOUND) { hr = HRESULT.S_OK; unk = null; } hr.ThrowIfFailed(); return((IShellItem2)unk); }