Skip to content

Commit 0415553

Browse files
authored
Merge pull request #1512 from dimhotepus/patch-2
Do not intermix BSTR and wchar_t as they are not compatible
2 parents ff1d6f0 + 3fcbab2 commit 0415553

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sdk-api-src/content/wbemcli/nf-wbemcli-iwbemlocator-connectserver.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ int _tmain(int argc, _TCHAR* argv[])
190190
// Connect to WMI through the IWbemLocator::ConnectServer method
191191
// Connect to the local ROOT\CIMV2 namespace
192192
// and obtain pointer pSvc to make IWbemServices calls.
193-
IWbemServices *pSvc = NULL;
194-
hres = pLoc->ConnectServer(L"ROOT\\CimV2", NULL,NULL, 0, NULL, 0, 0, &pSvc);
193+
IWbemServices *pSvc = NULL;
194+
BSTR namespace = SysAllocString(L"ROOT\\CimV2");
195+
hres = pLoc->ConnectServer(namespace, NULL, NULL, 0, NULL, 0, 0, &pSvc);
196+
SysFreeString(namespace);
195197

196198
if (FAILED(hres))
197199
{
@@ -222,4 +224,4 @@ int _tmain(int argc, _TCHAR* argv[])
222224
223225
224226
225-
<a href="/windows/win32/api/wbemcli/ne-wbemcli-wbem_connect_options">WBEM_CONNECT_OPTIONS</a>
227+
<a href="/windows/win32/api/wbemcli/ne-wbemcli-wbem_connect_options">WBEM_CONNECT_OPTIONS</a>

0 commit comments

Comments
 (0)