static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *url, LPSTR *ppszURL) { HRESULT hr = S_OK; InternetShortcut *This = impl_from_IUniformResourceLocatorA(url); TRACE("(%p, %p)\n", url, ppszURL); if (This->url == NULL) *ppszURL = NULL; else { *ppszURL = co_strdupWtoA(This->url); if (*ppszURL == NULL) hr = E_OUTOFMEMORY; } return hr; }
static HRESULT WINAPI UniformResourceLocatorA_GetUrl(IUniformResourceLocatorA *url, LPSTR *ppszURL) { InternetShortcut *This = impl_from_IUniformResourceLocatorA(url); TRACE("(%p, %p)\n", url, ppszURL); if (!This->url) { *ppszURL = NULL; return S_FALSE; } *ppszURL = co_strdupWtoA(This->url); if (!*ppszURL) return E_OUTOFMEMORY; return S_OK; }
static HRESULT WINAPI PersistFile_Load(IPersistFile *pFile, LPCOLESTR pszFileName, DWORD dwMode) { WCHAR str_header[] = {'I','n','t','e','r','n','e','t','S','h','o','r','t','c','u','t',0}; WCHAR str_URL[] = {'U','R','L',0}; WCHAR str_iconfile[] = {'i','c','o','n','f','i','l','e',0}; WCHAR str_iconindex[] = {'i','c','o','n','i','n','d','e','x',0}; WCHAR *filename = NULL; HRESULT hr; InternetShortcut *This = impl_from_IPersistFile(pFile); TRACE("(%p, %s, 0x%x)\n", pFile, debugstr_w(pszFileName), dwMode); if (dwMode != 0) FIXME("ignoring unimplemented mode 0x%x\n", dwMode); filename = co_strdupW(pszFileName); if (filename != NULL) { DWORD r; WCHAR *url; r = get_profile_string(str_header, str_URL, pszFileName, &url); if (url == NULL) { hr = E_OUTOFMEMORY; CoTaskMemFree(filename); } else if (r == 0) { hr = E_FAIL; CoTaskMemFree(filename); } else { hr = S_OK; CoTaskMemFree(This->currentFile); This->currentFile = filename; CoTaskMemFree(This->url); This->url = url; This->isDirty = FALSE; } /* Now we're going to read in the iconfile and iconindex. If we don't find them, that's not a failure case -- it's possible that they just aren't in there. */ if (SUCCEEDED(hr)) { IPropertyStorage *pPropStg; WCHAR *iconfile; WCHAR *iconindexstring; hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &pPropStg); r = get_profile_string(str_header, str_iconfile, pszFileName, &iconfile); if (iconfile != NULL) { PROPSPEC ps; PROPVARIANT pv; ps.ulKind = PRSPEC_PROPID; ps.u.propid = PID_IS_ICONFILE; pv.vt = VT_LPWSTR; pv.u.pwszVal = iconfile; hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0); if (FAILED(hr)) { TRACE("Failed to store the iconfile to our property storage. hr = 0x%x\n", hr); } CoTaskMemFree(iconfile); } r = get_profile_string(str_header, str_iconindex, pszFileName, &iconindexstring); if (iconindexstring != NULL) { int iconindex; PROPSPEC ps; PROPVARIANT pv; char *iconindexastring = co_strdupWtoA(iconindexstring); sscanf(iconindexastring, "%d", &iconindex); CoTaskMemFree(iconindexastring); ps.ulKind = PRSPEC_PROPID; ps.u.propid = PID_IS_ICONINDEX; pv.vt = VT_I4; pv.u.iVal = iconindex; hr = IPropertyStorage_WriteMultiple(pPropStg, 1, &ps, &pv, 0); if (FAILED(hr)) { TRACE("Failed to store the iconindex to our property storage. hr = 0x%x\n", hr); } CoTaskMemFree(iconindexstring); } IPropertyStorage_Release(pPropStg); } else hr = E_OUTOFMEMORY; } else hr = E_OUTOFMEMORY; return hr; }