Skip to content

Do not intermix BSTR and wchar_t as they are not compatible #1511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions sdk-api-src/content/wbemcli/nn-wbemcli-iwbemservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ The <b>IWbemServices</b> interface is used by clients and providers to access WM
```cpp
IWbemClassObject *pObj = NULL;

//The pWbemSvc pointer is of type IWbemServices*
pWbemSvc->GetObject(L"path", 0, 0, &pObj, 0);
// The pWbemSvc pointer is of type IWbemServices*
// BSTR is not compatible with wchar_t, need to allocate.
BSTR path = SysAllocString(L"path");
pWbemSvc->GetObject(path, 0, 0, &pObj, 0);
SysFreeString(path);
```

## -inheritance
Expand Down Expand Up @@ -118,20 +121,22 @@ IWbemServices *pWbemServices = NULL;

if (SUCCEEDED(hRes))
{
BSTR namespace = SysAllocString(L"root\\CIMV2");
hRes = pIWbemLocator->ConnectServer(
L"root\\CIMV2", // Namespace
NULL, // Userid
namespace, // Namespace
NULL, // Userid
NULL, // PW
NULL, // Locale
0, // flags
NULL, // Authority
NULL, // Context
&pWbemServices
);
SysFreeString(namespace);

pIWbemLocator->Release(); // Free memory resources.
pIWbemLocator->Release(); // Free memory resources.

// Use pWbemServices
// Use pWbemServices

}

Expand Down