mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 12:13:37 +00:00
wshom.ocx: Implement IWshNetwork2_get_UserName().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53971
This commit is contained in:
parent
090e574adb
commit
895f8006f2
|
@ -120,9 +120,25 @@ static HRESULT WINAPI WshNetwork2_get_UserDomain(IWshNetwork2 *iface, BSTR *user
|
||||||
|
|
||||||
static HRESULT WINAPI WshNetwork2_get_UserName(IWshNetwork2 *iface, BSTR *user_name)
|
static HRESULT WINAPI WshNetwork2_get_UserName(IWshNetwork2 *iface, BSTR *user_name)
|
||||||
{
|
{
|
||||||
FIXME("%p stub\n", user_name);
|
BOOL ret;
|
||||||
|
DWORD len = 0;
|
||||||
|
|
||||||
return E_NOTIMPL;
|
TRACE("%p\n", user_name);
|
||||||
|
|
||||||
|
GetUserNameW(NULL, &len);
|
||||||
|
*user_name = SysAllocStringLen(NULL, len-1);
|
||||||
|
if (!*user_name)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
ret = GetUserNameW(*user_name, &len);
|
||||||
|
if (!ret) {
|
||||||
|
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
|
||||||
|
SysFreeString(*user_name);
|
||||||
|
*user_name = NULL;
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI WshNetwork2_get_UserProfile(IWshNetwork2 *iface, BSTR *user_profile)
|
static HRESULT WINAPI WshNetwork2_get_UserProfile(IWshNetwork2 *iface, BSTR *user_profile)
|
||||||
|
|
|
@ -692,7 +692,11 @@ static void test_popup(void)
|
||||||
static void test_wshnetwork(void)
|
static void test_wshnetwork(void)
|
||||||
{
|
{
|
||||||
IDispatch *disp;
|
IDispatch *disp;
|
||||||
|
IWshNetwork2 *nw2;
|
||||||
|
BSTR str,username;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
DWORD len = 0;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
hr = CoCreateInstance(&CLSID_WshNetwork, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
hr = CoCreateInstance(&CLSID_WshNetwork, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
||||||
&IID_IDispatch, (void**)&disp);
|
&IID_IDispatch, (void**)&disp);
|
||||||
|
@ -703,6 +707,23 @@ static void test_wshnetwork(void)
|
||||||
check_interface(disp, &IID_IDispatchEx, FALSE);
|
check_interface(disp, &IID_IDispatchEx, FALSE);
|
||||||
check_interface(disp, &IID_IObjectWithSite, FALSE);
|
check_interface(disp, &IID_IObjectWithSite, FALSE);
|
||||||
|
|
||||||
|
hr = IDispatch_QueryInterface(disp, &IID_IWshNetwork2, (void**)&nw2);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||||
|
|
||||||
|
str = NULL;
|
||||||
|
hr = IWshNetwork2_get_UserName(nw2, &str);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||||
|
ok(str && str[0] != 0, "got empty string\n");
|
||||||
|
CHECK_BSTR_LENGTH(str);
|
||||||
|
GetUserNameW(NULL, &len);
|
||||||
|
ok(len > 0, "Unexpected len %ld.\n", len);
|
||||||
|
username = SysAllocStringLen(NULL, len-1);
|
||||||
|
ret = GetUserNameW(username, &len);
|
||||||
|
ok(ret == TRUE, "GetUserNameW returned %d.\n", ret);
|
||||||
|
ok(!wcscmp(str,username), "user names do not match %s %s.\n", debugstr_w(str), debugstr_w(username));
|
||||||
|
SysFreeString(username);
|
||||||
|
SysFreeString(str);
|
||||||
|
|
||||||
IDispatch_Release(disp);
|
IDispatch_Release(disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue