control.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Start a control panel applet or open the control panel window
  3. *
  4. * Copyright (C) 1998 by Marcel Baur <mbaur@g26.ethz.ch>
  5. * Copyright 2010 Detlef Riekenberg
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. #define WIN32_LEAN_AND_MEAN
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <windows.h>
  25. #include <commctrl.h>
  26. #include <shellapi.h>
  27. extern void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow);
  28. static void launch(LPCWSTR what)
  29. {
  30. Control_RunDLLW(GetDesktopWindow(), 0, what, SW_SHOW);
  31. ExitProcess(0);
  32. }
  33. int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpszCmdLine, INT nCmdShow)
  34. {
  35. InitCommonControls();
  36. /* no parameters - pop up whole "Control Panel" by default */
  37. if (!*lpszCmdLine) {
  38. launch(lpszCmdLine);
  39. }
  40. /* check for optional parameter */
  41. if (!lstrcmpiW(lpszCmdLine, L"COLOR"))
  42. launch(L"desk.cpl,,2");
  43. if (!lstrcmpiW(lpszCmdLine, L"DATE/TIME"))
  44. launch(L"timedate.cpl");
  45. if (!lstrcmpiW(lpszCmdLine, L"DESKTOP"))
  46. launch(L"desk.cpl");
  47. if (!lstrcmpiW(lpszCmdLine, L"INTERNATIONAL"))
  48. launch(L"intl.cpl");
  49. if (!lstrcmpiW(lpszCmdLine, L"KEYBOARD"))
  50. launch(L"main.cpl @1");
  51. if (!lstrcmpiW(lpszCmdLine, L"MOUSE"))
  52. launch(L"main.cpl");
  53. if (!lstrcmpiW(lpszCmdLine, L"PORTS"))
  54. launch(L"sysdm.cpl,,1");
  55. if (!lstrcmpiW(lpszCmdLine, L"PRINTERS"))
  56. launch(L"main.cpl @2");
  57. /* try to launch if a .cpl file is given directly */
  58. launch(lpszCmdLine);
  59. return 0;
  60. }