1 /*--------------------------------------------------------------------------*/
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) INRIA - Allan CORNET
4 //
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
6 //
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
13 /*--------------------------------------------------------------------------*/
14 #include "windows_tools_gw.hxx"
15 #include "function.hxx"
16 #include "string.hxx"
17 #include "registry.hxx"
18
19 extern "C"
20 {
21 #include "Scierror.h"
22 #include "localization.h"
23 }
24 /*--------------------------------------------------------------------------*/
25 static int getnIndexFromString(const std::wstring& cmd);
26 /*--------------------------------------------------------------------------*/
27 const std::string fname = "getsystemmetrics";
28 /*--------------------------------------------------------------------------*/
sci_getsystemmetrics(types::typed_list & in,int _iRetCount,types::typed_list & out)29 types::Function::ReturnValue sci_getsystemmetrics(types::typed_list &in, int _iRetCount, types::typed_list &out)
30 {
31 types::String* pS = nullptr;
32 std::wstring param1;
33
34 if (in.size() != 1)
35 {
36 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname.data(), 1);
37 return types::Function::Error;
38 }
39
40 if (_iRetCount > 1)
41 {
42 Scierror(999, _("%s: Wrong number of output arguments: %d expected.\n"), fname.data(), 1);
43 return types::Function::Error;
44 }
45
46 pS = in[0]->getAs<types::String>();
47 param1 = pS->get()[0];
48
49 int val = getnIndexFromString(param1);
50 if (val != -1)
51 {
52 out.push_back(new types::Double(GetSystemMetrics(val)));
53 }
54 else
55 {
56 Scierror(999, _("%s: Wrong value for input argument: %s.\n"), fname.data(), _("see help"));
57 return types::Function::Error;
58 }
59 return types::Function::OK;
60 }
61 /*--------------------------------------------------------------------------*/
getnIndexFromString(const std::wstring & cmd)62 static int getnIndexFromString(const std::wstring& cmd)
63 {
64 if (L"SM_ARRANGE" == cmd)
65 {
66 return SM_ARRANGE;
67 }
68 if (L"SM_CLEANBOOT" == cmd)
69 {
70 return SM_CLEANBOOT;
71 }
72 if (L"SM_CMONITORS" == cmd)
73 {
74 return SM_CMONITORS;
75 }
76 if (L"SM_CMOUSEBUTTONS" == cmd)
77 {
78 return SM_CMOUSEBUTTONS;
79 }
80 if (L"SM_CXBORDER" == cmd)
81 {
82 return SM_CXBORDER;
83 }
84 if (L"SM_CXCURSOR" == cmd)
85 {
86 return SM_CXCURSOR;
87 }
88 if (L"SM_CXDLGFRAME" == cmd)
89 {
90 return SM_CXDLGFRAME;
91 }
92 if (L"SM_CXDOUBLECLK" == cmd)
93 {
94 return SM_CXDOUBLECLK;
95 }
96 if (L"SM_CXDRAG" == cmd)
97 {
98 return SM_CXDRAG;
99 }
100 if (L"SM_CXEDGE" == cmd)
101 {
102 return SM_CXEDGE;
103 }
104 if (L"SM_CXFIXEDFRAME" == cmd)
105 {
106 return SM_CXFIXEDFRAME;
107 }
108 if (L"SM_CXFOCUSBORDER" == cmd)
109 {
110 return SM_CXFOCUSBORDER;
111 }
112 if (L"SM_CXFRAME" == cmd)
113 {
114 return SM_CXFRAME;
115 }
116 if (L"SM_CXFULLSCREEN" == cmd)
117 {
118 return SM_CXFULLSCREEN;
119 }
120 if (L"SM_CXHSCROLL" == cmd)
121 {
122 return SM_CXHSCROLL;
123 }
124 if (L"SM_CXHTHUMB" == cmd)
125 {
126 return SM_CXHTHUMB;
127 }
128 if (L"SM_CXICON" == cmd)
129 {
130 return SM_CXICON;
131 }
132 if (L"SM_CXICONSPACING" == cmd)
133 {
134 return SM_CXICONSPACING;
135 }
136 if (L"SM_CXMAXIMIZED" == cmd)
137 {
138 return SM_CXMAXIMIZED;
139 }
140 if (L"SM_CXMAXTRACK" == cmd)
141 {
142 return SM_CXMAXTRACK;
143 }
144 if (L"SM_CXMENUCHECK" == cmd)
145 {
146 return SM_CXMENUCHECK;
147 }
148 if (L"SM_CXMENUSIZE" == cmd)
149 {
150 return SM_CXMENUSIZE;
151 }
152 if (L"SM_CXMIN" == cmd)
153 {
154 return SM_CXMIN;
155 }
156 if (L"SM_CXMINIMIZED" == cmd)
157 {
158 return SM_CXMINIMIZED;
159 }
160 if (L"SM_CXMINSPACING" == cmd)
161 {
162 return SM_CXMINSPACING;
163 }
164 if (L"SM_CXMINTRACK" == cmd)
165 {
166 return SM_CXMINTRACK;
167 }
168 if (L"SM_CXPADDEDBORDER" == cmd)
169 {
170 return SM_CXPADDEDBORDER;
171 }
172 if (L"SM_CXSCREEN" == cmd)
173 {
174 return SM_CXSCREEN;
175 }
176 if (L"SM_CXSIZE" == cmd)
177 {
178 return SM_CXSIZE;
179 }
180 if (L"SM_CXSIZEFRAME" == cmd)
181 {
182 return SM_CXSIZEFRAME;
183 }
184 if (L"SM_CXSMICON" == cmd)
185 {
186 return SM_CXSMICON;
187 }
188 if (L"SM_CXSMSIZE" == cmd)
189 {
190 return SM_CXSMSIZE;
191 }
192 if (L"SM_CXVIRTUALSCREEN" == cmd)
193 {
194 return SM_CXVIRTUALSCREEN;
195 }
196 if (L"SM_CXVSCROLL" == cmd)
197 {
198 return SM_CXVSCROLL;
199 }
200 if (L"SM_CYBORDER" == cmd)
201 {
202 return SM_CYBORDER;
203 }
204 if (L"SM_CYCAPTION" == cmd)
205 {
206 return SM_CYCAPTION;
207 }
208 if (L"SM_CYCURSOR" == cmd)
209 {
210 return SM_CYCURSOR;
211 }
212 if (L"SM_CYDLGFRAME" == cmd)
213 {
214 return SM_CYDLGFRAME;
215 }
216 if (L"SM_CYDOUBLECLK" == cmd)
217 {
218 return SM_CYDOUBLECLK;
219 }
220 if (L"SM_CYDRAG" == cmd)
221 {
222 return SM_CYDRAG;
223 }
224 if (L"SM_CYEDGE" == cmd)
225 {
226 return SM_CYEDGE;
227 }
228 if (L"SM_CYFIXEDFRAME" == cmd)
229 {
230 return SM_CYFIXEDFRAME;
231 }
232 if (L"SM_CYFOCUSBORDER" == cmd)
233 {
234 return SM_CYFOCUSBORDER;
235 }
236 if (L"SM_CYFRAME" == cmd)
237 {
238 return SM_CYFRAME;
239 }
240 if (L"SM_CYFULLSCREEN" == cmd)
241 {
242 return SM_CYFULLSCREEN;
243 }
244 if (L"SM_CYHSCROLL" == cmd)
245 {
246 return SM_CYHSCROLL;
247 }
248 if (L"SM_CYICON" == cmd)
249 {
250 return SM_CYICON;
251 }
252 if (L"SM_CYICONSPACING" == cmd)
253 {
254 return SM_CYICONSPACING;
255 }
256 if (L"SM_CYKANJIWINDOW" == cmd)
257 {
258 return SM_CYKANJIWINDOW;
259 }
260 if (L"SM_CYMAXIMIZED" == cmd)
261 {
262 return SM_CYMAXIMIZED;
263 }
264 if (L"SM_CYMAXTRACK" == cmd)
265 {
266 return SM_CYMAXTRACK;
267 }
268 if (L"SM_CYMENU" == cmd)
269 {
270 return SM_CYMENU;
271 }
272 if (L"SM_CYMENUCHECK" == cmd)
273 {
274 return SM_CYMENUCHECK;
275 }
276 if (L"SM_CYMENUSIZE" == cmd)
277 {
278 return SM_CYMENUSIZE;
279 }
280 if (L"SM_CYMIN" == cmd)
281 {
282 return SM_CYMIN;
283 }
284 if (L"SM_CYMINIMIZED" == cmd)
285 {
286 return SM_CYMINIMIZED;
287 }
288 if (L"SM_CYMINSPACING" == cmd)
289 {
290 return SM_CYMINSPACING;
291 }
292 if (L"SM_CYMINTRACK" == cmd)
293 {
294 return SM_CYMINTRACK;
295 }
296 if (L"SM_CYSCREEN" == cmd)
297 {
298 return SM_CYSCREEN;
299 }
300 if (L"SM_CYSIZE" == cmd)
301 {
302 return SM_CYSIZE;
303 }
304 if (L"SM_CYSIZEFRAME" == cmd)
305 {
306 return SM_CYSIZEFRAME;
307 }
308 if (L"SM_CYSMCAPTION" == cmd)
309 {
310 return SM_CYSMCAPTION;
311 }
312 if (L"SM_CYSMICON" == cmd)
313 {
314 return SM_CYSMICON;
315 }
316 if (L"SM_CYSMSIZE" == cmd)
317 {
318 return SM_CYSMSIZE;
319 }
320 if (L"SM_CYVIRTUALSCREEN" == cmd)
321 {
322 return SM_CYVIRTUALSCREEN;
323 }
324 if (L"SM_CYVSCROLL" == cmd)
325 {
326 return SM_CYVSCROLL;
327 }
328 if (L"SM_CYVTHUMB" == cmd)
329 {
330 return SM_CYVTHUMB;
331 }
332 if (L"SM_DBCSENABLED" == cmd)
333 {
334 return SM_DBCSENABLED;
335 }
336 if (L"SM_DEBUG" == cmd)
337 {
338 return SM_DEBUG;
339 }
340 if (L"SM_IMMENABLED" == cmd)
341 {
342 return SM_IMMENABLED;
343 }
344 if (L"SM_MEDIACENTER" == cmd)
345 {
346 return SM_MEDIACENTER;
347 }
348 if (L"SM_MENUDROPALIGNMENT" == cmd)
349 {
350 return SM_MENUDROPALIGNMENT;
351 }
352 if (L"SM_MIDEASTENABLED" == cmd)
353 {
354 return SM_MIDEASTENABLED;
355 }
356 if (L"SM_MOUSEPRESENT" == cmd)
357 {
358 return SM_MOUSEPRESENT;
359 }
360 if (L"SM_MOUSEHORIZONTALWHEELPRESENT" == cmd)
361 {
362 return SM_MOUSEHORIZONTALWHEELPRESENT;
363 }
364 if (L"SM_MOUSEWHEELPRESENT" == cmd)
365 {
366 return SM_MOUSEWHEELPRESENT;
367 }
368 if (L"SM_NETWORK" == cmd)
369 {
370 return SM_NETWORK;
371 }
372 if (L"SM_PENWINDOWS" == cmd)
373 {
374 return SM_PENWINDOWS;
375 }
376 if (L"SM_REMOTECONTROL" == cmd)
377 {
378 return SM_REMOTECONTROL;
379 }
380 if (L"SM_REMOTESESSION" == cmd)
381 {
382 return SM_REMOTESESSION;
383 }
384 if (L"SM_SAMEDISPLAYFORMAT" == cmd)
385 {
386 return SM_SAMEDISPLAYFORMAT;
387 }
388 if (L"SM_SECURE" == cmd)
389 {
390 return SM_SECURE;
391 }
392 if (L"SM_SERVERR2" == cmd)
393 {
394 return SM_SERVERR2;
395 }
396 if (L"SM_SHOWSOUNDS" == cmd)
397 {
398 return SM_SHOWSOUNDS;
399 }
400 if (L"SM_SHUTTINGDOWN" == cmd)
401 {
402 return SM_SHUTTINGDOWN;
403 }
404 if (L"SM_SLOWMACHINE" == cmd)
405 {
406 return SM_SLOWMACHINE;
407 }
408 if (L"SM_STARTER" == cmd)
409 {
410 return SM_STARTER;
411 }
412 if (L"SM_SWAPBUTTON" == cmd)
413 {
414 return SM_SWAPBUTTON;
415 }
416 if (L"SM_TABLETPC" == cmd)
417 {
418 return SM_TABLETPC;
419 }
420 if (L"SM_XVIRTUALSCREEN" == cmd)
421 {
422 return SM_XVIRTUALSCREEN;
423 }
424 if (L"SM_YVIRTUALSCREEN" == cmd)
425 {
426 return SM_YVIRTUALSCREEN;
427 }
428 return -1;
429 }
430 /*--------------------------------------------------------------------------*/
431