ConvertStringToBSTR

Microsoft 固有の仕様 →

BSTRchar * の値を変換します。

BSTR __stdcall ConvertStringToBSTR(
   const char* pSrc
)

パラメーター

  • pSrc
    char * の変数。

使用例

// ConvertStringToBSTR.cpp
#include <comutil.h>
#include <stdio.h>

#pragma comment(lib, "comsuppw.lib")
#pragma comment(lib, "kernel32.lib")

int main() {
   char* lpszText = "Test";
   printf_s("char * text: %s\n", lpszText);

   BSTR bstrText = _com_util::ConvertStringToBSTR(lpszText);
   wprintf_s(L"BSTR text: %s\n", bstrText);

   SysFreeString(bstrText);
}
  

必要条件

ヘッダー : comutil.h

ライブラリ : comsuppw.lib または comsuppwd.lib (詳細については /Zc:wchar_t (wchar_t をネイティブ型として認識) を参照してください)

参照

関連項目

コンパイラ COM のグローバル関数