ReactOS
0.4.16-dev-983-g23ad936
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
Functions
_com_util Namespace Reference
Functions
BSTR
WINAPI
ConvertStringToBSTR
(
const
char
*pSrc)
char
*
WINAPI
ConvertBSTRToString
(
BSTR
pSrc)
Function Documentation
◆
ConvertBSTRToString()
char
*
WINAPI
_com_util::ConvertBSTRToString
(
BSTR
pSrc
)
Definition at line
93
of file
comsupp.cpp
.
94
{
95
DWORD
cb
, cwch;
96
char
*szOut =
NULL
;
97
98
if
(!pSrc)
return
NULL
;
99
100
/* Retrieve the size of the BSTR with the NULL terminator */
101
cwch =
::SysStringLen
(pSrc) + 1;
102
103
/* Compute the needed size with the NULL terminator */
104
cb
=
::WideCharToMultiByte
(
CP_ACP
, 0, pSrc, cwch,
NULL
, 0,
NULL
,
NULL
);
105
if
(
cb
== 0)
106
{
107
cwch =
::GetLastError
();
108
::_com_issue_error
(!
IS_ERROR
(cwch) ?
HRESULT_FROM_WIN32
(cwch) : cwch);
109
return
NULL
;
110
}
111
112
/* Allocate the string */
113
szOut = (
char
*)
::operator
new
(
cb
*
sizeof
(
char
));
114
if
(!szOut)
115
{
116
::_com_issue_error
(
HRESULT_FROM_WIN32
(
ERROR_OUTOFMEMORY
));
117
return
NULL
;
118
}
119
120
/* Convert the string and NULL-terminate */
121
szOut[
cb
- 1] =
'\0'
;
122
if
(
::WideCharToMultiByte
(
CP_ACP
, 0, pSrc, cwch, szOut,
cb
,
NULL
,
NULL
) == 0)
123
{
124
/* We failed, clean everything up */
125
cwch =
::GetLastError
();
126
127
::operator
delete
(szOut);
128
szOut =
NULL
;
129
130
::_com_issue_error
(!
IS_ERROR
(cwch) ?
HRESULT_FROM_WIN32
(cwch) : cwch);
131
}
132
133
return
szOut;
134
}
_com_issue_error
void WINAPI _com_issue_error(HRESULT hr)
Definition:
comsupp.cpp:32
ERROR_OUTOFMEMORY
#define ERROR_OUTOFMEMORY
Definition:
deptool.c:13
NULL
#define NULL
Definition:
types.h:112
CP_ACP
#define CP_ACP
Definition:
compat.h:109
WideCharToMultiByte
#define WideCharToMultiByte
Definition:
compat.h:111
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
cb
static HMODULE MODULEINFO DWORD cb
Definition:
module.c:33
SysStringLen
UINT WINAPI SysStringLen(BSTR str)
Definition:
oleaut.c:196
operator
operator
Definition:
wbemprox_private.h:48
GetLastError
DWORD WINAPI GetLastError(void)
Definition:
except.c:1042
IS_ERROR
#define IS_ERROR(stat)
Definition:
winerror.h:74
HRESULT_FROM_WIN32
#define HRESULT_FROM_WIN32(x)
Definition:
winerror.h:92
◆
ConvertStringToBSTR()
BSTR
WINAPI
_com_util::ConvertStringToBSTR
(
const
char
*
pSrc
)
Definition at line
59
of file
comsupp.cpp
.
60
{
61
DWORD
cwch;
62
BSTR
wsOut(
NULL
);
63
64
if
(!pSrc)
return
NULL
;
65
66
/* Compute the needed size with the NULL terminator */
67
cwch =
::MultiByteToWideChar
(
CP_ACP
, 0, pSrc, -1,
NULL
, 0);
68
if
(cwch == 0)
return
NULL
;
69
70
/* Allocate the BSTR (without the NULL terminator) */
71
wsOut =
::SysAllocStringLen
(
NULL
, cwch - 1);
72
if
(!wsOut)
73
{
74
::_com_issue_error
(
HRESULT_FROM_WIN32
(
ERROR_OUTOFMEMORY
));
75
return
NULL
;
76
}
77
78
/* Convert the string */
79
if
(
::MultiByteToWideChar
(
CP_ACP
, 0, pSrc, -1, wsOut, cwch) == 0)
80
{
81
/* We failed, clean everything up */
82
cwch =
::GetLastError
();
83
84
::SysFreeString
(wsOut);
85
wsOut =
NULL
;
86
87
::_com_issue_error
(!
IS_ERROR
(cwch) ?
HRESULT_FROM_WIN32
(cwch) : cwch);
88
}
89
90
return
wsOut;
91
}
BSTR
OLECHAR * BSTR
Definition:
compat.h:2293
MultiByteToWideChar
#define MultiByteToWideChar
Definition:
compat.h:110
SysFreeString
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition:
oleaut.c:271
SysAllocStringLen
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition:
oleaut.c:339
_com_util
Generated on Thu Apr 17 2025 06:32:50 for ReactOS by
1.9.6