diff --git a/dlls/hlink/hlink.spec b/dlls/hlink/hlink.spec index 0d9a2c9cfd8..c0386b5ae9b 100644 --- a/dlls/hlink/hlink.spec +++ b/dlls/hlink/hlink.spec @@ -17,7 +17,7 @@ 22 stub HlinkGetSpecialReference 23 stub HlinkCreateShortcut 24 stub HlinkResolveShortcut -25 stub HlinkIsShortcut +25 stdcall HlinkIsShortcut(wstr) 26 stub HlinkResolveShortcutToString 27 stub HlinkCreateShortcutFromString 28 stub HlinkGetValueFromParams diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index dfa4464bc14..bd1ed6ea4dc 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -31,6 +31,7 @@ #include "unknwn.h" #include "wine/debug.h" +#include "wine/unicode.h" #include "hlink.h" #include "initguid.h" @@ -254,6 +255,24 @@ HRESULT WINAPI HlinkNavigateToStringReference( LPCWSTR pwzTarget, return r; } +HRESULT WINAPI HlinkIsShortcut(LPCWSTR pwzFileName) +{ + int len; + + static const WCHAR url_ext[] = {'.','u','r','l',0}; + + TRACE("(%s)\n", debugstr_w(pwzFileName)); + + if(!pwzFileName) + return E_INVALIDARG; + + len = strlenW(pwzFileName)-4; + if(len < 0) + return S_FALSE; + + return strcmpiW(pwzFileName+len, url_ext) ? S_FALSE : S_OK; +} + static HRESULT WINAPI HLinkCF_fnQueryInterface ( LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj) { diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index 47bf80f1360..e44a7995a59 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -25,6 +25,42 @@ #include "wine/test.h" +static void test_HlinkIsShortcut(void) +{ + int i; + HRESULT hres; + + static const WCHAR file0[] = {'f','i','l','e',0}; + static const WCHAR file1[] = {'f','i','l','e','.','u','r','l',0}; + static const WCHAR file2[] = {'f','i','l','e','.','l','n','k',0}; + static const WCHAR file3[] = {'f','i','l','e','.','u','R','l',0}; + static const WCHAR file4[] = {'f','i','l','e','u','r','l',0}; + static const WCHAR file5[] = {'c',':','\\','f','i','l','e','.','u','r','l',0}; + static const WCHAR file6[] = {'c',':','\\','f','i','l','e','.','l','n','k',0}; + static const WCHAR file7[] = {'.','u','r','l',0}; + + static struct { + LPCWSTR file; + HRESULT hres; + } shortcut_test[] = { + {file0, S_FALSE}, + {file1, S_OK}, + {file2, S_FALSE}, + {file3, S_OK}, + {file4, S_FALSE}, + {file5, S_OK}, + {file6, S_FALSE}, + {file7, S_OK}, + {NULL, E_INVALIDARG} + }; + + for(i=0; i