From: Alex Henrie alexhenrie24@gmail.com
--- include/Makefile.in | 1 + include/atlconv.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 include/atlconv.h
diff --git a/include/Makefile.in b/include/Makefile.in index e9f0aa8d5fb..a0058266e28 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -27,6 +27,7 @@ SOURCES = \ asysta.idl \ atlbase.h \ atlcom.h \ + atlconv.h \ atliface.idl \ atlthunk.h \ atlwin.h \ diff --git a/include/atlconv.h b/include/atlconv.h new file mode 100644 index 00000000000..bc57937425d --- /dev/null +++ b/include/atlconv.h @@ -0,0 +1,35 @@ +/* + * Copyright 2023 Alex Henrie + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __ATLCONV_H__ +#define __ATLCONV_H__ + +inline BSTR A2BSTR(const char *s) +{ + BSTR ret; + int len; + + len = MultiByteToWideChar(CP_ACP, 0, s, -1, NULL, 0); + ret = SysAllocStringLen(NULL, len - 1); + if (!ret) return NULL; + MultiByteToWideChar(CP_ACP, 0, s, -1, ret, len); + + return ret; +} + +#endif /* __ATLCONV_H__ */