user32: Fix SPI_SETMOUSESPEED handling, the parameter is not a pointer.
[wine/wine64.git] / dlls / oleaut32 / ole2disp.c
bloba09ef7c62f7f68daee4eafd504499a0d9e93ff58
1 /*
2 * OLE2DISP library
4 * Copyright 1995 Martin von Loewis
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <stdarg.h>
24 #include <string.h>
26 #include "wine/windef16.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "oleauto.h"
33 #include "winerror.h"
35 #include "ole2disp.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ole);
41 /* This implementation of the BSTR API is 16-bit only. It
42 represents BSTR as a 16:16 far pointer, and the strings
43 as ISO-8859 */
45 /******************************************************************************
46 * BSTR_AllocBytes [Internal]
48 static BSTR16 BSTR_AllocBytes(int n)
50 void *ptr = HeapAlloc( GetProcessHeap(), 0, n );
51 return (BSTR16)MapLS(ptr);
54 /******************************************************************************
55 * BSTR_Free [INTERNAL]
57 static void BSTR_Free(BSTR16 in)
59 void *ptr = MapSL( (SEGPTR)in );
60 UnMapLS( (SEGPTR)in );
61 HeapFree( GetProcessHeap(), 0, ptr );
64 /******************************************************************************
65 * BSTR_GetAddr [INTERNAL]
67 static void* BSTR_GetAddr(BSTR16 in)
69 return in ? MapSL((SEGPTR)in) : 0;
72 /******************************************************************************
73 * SysAllocString [OLE2DISP.2]
75 * Create a BSTR16 from an OLESTR16 (16 Bit).
77 * PARAMS
78 * oleStr [I] Source to create BSTR16 from
80 * RETURNS
81 * Success: A BSTR16 allocated with SysAllocStringLen16().
82 * Failure: NULL, if oleStr is NULL.
84 BSTR16 WINAPI SysAllocString16(LPCOLESTR16 oleStr)
86 BSTR16 out;
88 if (!oleStr) return 0;
90 out = BSTR_AllocBytes(strlen(oleStr)+1);
91 if (!out) return 0;
92 strcpy(BSTR_GetAddr(out),oleStr);
93 return out;
96 /******************************************************************************
97 * SysReallocString [OLE2DISP.3]
99 * Change the length of a previously created BSTR16 (16 Bit).
101 * PARAMS
102 * pbstr [I] BSTR16 to change the length of
103 * oleStr [I] New source for pbstr
105 * RETURNS
106 * Success: 1
107 * Failure: 0.
109 * NOTES
110 * SysAllocStringStringLen16().
112 INT16 WINAPI SysReAllocString16(LPBSTR16 pbstr,LPCOLESTR16 oleStr)
114 BSTR16 new=SysAllocString16(oleStr);
115 BSTR_Free(*pbstr);
116 *pbstr=new;
117 return 1;
120 /******************************************************************************
121 * SysAllocStringLen [OLE2DISP.4]
123 * Create a BSTR16 from an OLESTR16 of a given character length (16 Bit).
125 * PARAMS
126 * oleStr [I] Source to create BSTR16 from
127 * len [I] Length of oleStr in wide characters
129 * RETURNS
130 * Success: A newly allocated BSTR16 from SysAllocStringByteLen16()
131 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
133 * NOTES
134 * See SysAllocStringByteLen16().
136 BSTR16 WINAPI SysAllocStringLen16(const char *oleStr, int len)
138 BSTR16 out=BSTR_AllocBytes(len+1);
140 if (!out)
141 return 0;
144 * Copy the information in the buffer.
145 * Since it is valid to pass a NULL pointer here, we'll initialize the
146 * buffer to nul if it is the case.
148 if (oleStr != 0)
149 strcpy(BSTR_GetAddr(out),oleStr);
150 else
151 memset(BSTR_GetAddr(out), 0, len+1);
153 return out;
156 /******************************************************************************
157 * SysReAllocStringLen [OLE2DISP.5]
159 * Change the length of a previously created BSTR16 (16 Bit).
161 * PARAMS
162 * pbstr [I] BSTR16 to change the length of
163 * oleStr [I] New source for pbstr
164 * len [I] Length of oleStr in characters
166 * RETURNS
167 * Success: 1. The size of pbstr is updated.
168 * Failure: 0, if len >= 0x8000 or memory allocation fails.
170 * NOTES
171 * See SysAllocStringByteLen16().
172 * *pbstr may be changed by this function.
174 int WINAPI SysReAllocStringLen16(BSTR16 *old,const char *in,int len)
176 /* FIXME: Check input length */
177 BSTR16 new=SysAllocStringLen16(in,len);
178 BSTR_Free(*old);
179 *old=new;
180 return 1;
183 /******************************************************************************
184 * SysFreeString [OLE2DISP.6]
186 * Free a BSTR16 (16 Bit).
188 * PARAMS
189 * str [I] String to free.
191 * RETURNS
192 * Nothing.
194 void WINAPI SysFreeString16(BSTR16 str)
196 BSTR_Free(str);
199 /******************************************************************************
200 * SysStringLen [OLE2DISP.7]
202 * Get the allocated length of a BSTR16 in characters (16 Bit).
204 * PARAMS
205 * str [I] BSTR16 to find the length of
207 * RETURNS
208 * The allocated length of str, or 0 if str is NULL.
210 int WINAPI SysStringLen16(BSTR16 str)
212 return strlen(BSTR_GetAddr(str));
215 /******************************************************************************
216 * CreateDispTypeInfo [OLE2DISP.31]
218 HRESULT WINAPI CreateDispTypeInfo16(
219 INTERFACEDATA *pidata,
220 LCID lcid,
221 ITypeInfo **pptinfo)
223 FIXME("(%p,%d,%p),stub\n",pidata,lcid,pptinfo);
224 return E_NOTIMPL;
227 /******************************************************************************
228 * CreateStdDispatch [OLE2DISP.32]
230 HRESULT WINAPI CreateStdDispatch16(
231 IUnknown* punkOuter,
232 void* pvThis,
233 ITypeInfo* ptinfo,
234 IUnknown** ppunkStdDisp)
236 FIXME("(%p,%p,%p,%p),stub\n",punkOuter, pvThis, ptinfo,
237 ppunkStdDisp);
238 return 0;
241 /******************************************************************************
242 * RegisterActiveObject [OLE2DISP.35]
244 HRESULT WINAPI RegisterActiveObject16(
245 IUnknown *punk, REFCLSID rclsid, DWORD dwFlags, unsigned long *pdwRegister
247 FIXME("(%p,%s,0x%08x,%p):stub\n",punk,debugstr_guid(rclsid),dwFlags,pdwRegister);
248 return E_NOTIMPL;