Commit 895f8006 authored by Robert Wilhelm's avatar Robert Wilhelm Committed by Alexandre Julliard

wshom.ocx: Implement IWshNetwork2_get_UserName().

parent 090e574a
......@@ -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)
{
FIXME("%p stub\n", user_name);
BOOL ret;
DWORD len = 0;
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 E_NOTIMPL;
return S_OK;
}
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)
{
IDispatch *disp;
IWshNetwork2 *nw2;
BSTR str,username;
HRESULT hr;
DWORD len = 0;
BOOL ret;
hr = CoCreateInstance(&CLSID_WshNetwork, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IDispatch, (void**)&disp);
......@@ -703,6 +707,23 @@ static void test_wshnetwork(void)
check_interface(disp, &IID_IDispatchEx, 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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment