void FrameworkView::LaunchActivated(ComPtr<ILaunchActivatedEventArgs>& aArgs, bool aStartup) { if (!aArgs) return; HString data; AssertHRESULT(aArgs->get_Arguments(data.GetAddressOf())); if (WindowsIsStringEmpty(data.Get())) return; // If we're being launched from a secondary tile then we have a 2nd command line param of -url // and a third of the secondary tile. We want it in sActivationURI so that browser.js will // load it in without showing the start UI. int argc; unsigned int length; LPWSTR* argv = CommandLineToArgvW(data.GetRawBuffer(&length), &argc); if (aStartup && argc == 2 && !wcsicmp(argv[0], L"-url")) { WindowsCreateString(argv[1], wcslen(argv[1]), &sActivationURI); } else { // Some other command line or this is not a startup. // If it is startup we process it later when XPCOM is initialilzed. mActivationCommandLine = data.GetRawBuffer(&length); if (!aStartup) { ProcessLaunchArguments(); } } }
/*********************************************************************** * WindowsDuplicateString (combase.@) */ HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out) { struct hstring_private *priv = impl_from_HSTRING(str); if (out == NULL) return E_INVALIDARG; if (str == NULL) { *out = NULL; return S_OK; } if (priv->reference) return WindowsCreateString(priv->buffer, priv->length, out); InterlockedIncrement(&priv->refcount); *out = str; return S_OK; }
/*********************************************************************** * WindowsSubstringWithSpecifiedLength (combase.@) */ HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 start, UINT32 len, HSTRING *out) { struct hstring_private *priv = impl_from_HSTRING(str); TRACE("(%p, %u, %u, %p)\n", str, start, len, out); if (out == NULL) return E_INVALIDARG; if (start + len < start || start + len > WindowsGetStringLen(str)) return E_BOUNDS; if (len == 0) { *out = NULL; return S_OK; } return WindowsCreateString(&priv->buffer[start], len, out); }
/*********************************************************************** * WindowsSubstring (combase.@) */ HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 start, HSTRING *out) { struct hstring_private *priv = impl_from_HSTRING(str); UINT32 len = WindowsGetStringLen(str); TRACE("(%p, %u, %p)\n", str, start, out); if (out == NULL) return E_INVALIDARG; if (start > len) return E_BOUNDS; if (start == len) { *out = NULL; return S_OK; } return WindowsCreateString(&priv->buffer[start], len - start, out); }
/*********************************************************************** * WindowsTrimStringEnd (combase.@) */ HRESULT WINAPI WindowsTrimStringEnd(HSTRING str1, HSTRING str2, HSTRING *out) { struct hstring_private *priv1 = impl_from_HSTRING(str1); struct hstring_private *priv2 = impl_from_HSTRING(str2); UINT32 len; TRACE("(%p, %p, %p)\n", str1, str2, out); if (!out || !str2 || !priv2->length) return E_INVALIDARG; if (!str1) { *out = NULL; return S_OK; } for (len = priv1->length; len > 0; len--) { if (!wmemchr(priv2->buffer, priv1->buffer[len - 1], priv2->length)) break; } return (len < priv1->length) ? WindowsCreateString(priv1->buffer, len, out) : WindowsDuplicateString(str1, out); }
/*********************************************************************** * WindowsTrimStringStart (combase.@) */ HRESULT WINAPI WindowsTrimStringStart(HSTRING str1, HSTRING str2, HSTRING *out) { struct hstring_private *priv1 = impl_from_HSTRING(str1); struct hstring_private *priv2 = impl_from_HSTRING(str2); UINT32 start; TRACE("(%p, %p, %p)\n", str1, str2, out); if (!out || !str2 || !priv2->length) return E_INVALIDARG; if (!str1) { *out = NULL; return S_OK; } for (start = 0; start < priv1->length; start++) { if (!wmemchr(priv2->buffer, priv1->buffer[start], priv2->length)) break; } return start ? WindowsCreateString(&priv1->buffer[start], priv1->length - start, out) : WindowsDuplicateString(str1, out); }
EXTERN_C HRESULT WINAPI CreateString(PCWSTR Str, HSTRING*pHS) { return WindowsCreateString(Str, lstrlenW(Str), pHS); }
long __stdcall __windowsCreateString(const __wchar_t* sourceString, int length, __abi_HSTRING* string) { return WindowsCreateString(sourceString, length, (HSTRING*)string); }