source: trunk/Utilities/Miscellaneous/SoundControlPanelApplet/SoundControlPanelApplet.cpp @ 160

Last change on this file since 160 was 160, checked in by roman, 11 years ago
File size: 2.9 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2012-2013
3// Created by Roman Ryltsov roman@alax.info
4
5#include "stdafx.h"
6#include <commctrl.h>
7#include <cpl.h>
8
9#pragma comment(lib, "comctl32.lib")
10
11int _tmain(int argc, _TCHAR* argv[])
12{
13        INITCOMMONCONTROLSEX Data = { sizeof Data, ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES };
14        ATLVERIFY(InitCommonControlsEx(&Data));
15        HMODULE hModule = LoadLibrary(_T("mmsys.cpl"));
16        typedef LONG (WINAPI *CPLAPPLET)(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
17        CPLAPPLET pCplApplet = (CPLAPPLET) GetProcAddress(hModule, "CPlApplet");
18        LONG nResult;
19        nResult = pCplApplet(GetActiveWindow(), CPL_INIT, 0, 0);
20        if(nResult)
21        {
22                nResult = pCplApplet(GetActiveWindow(), CPL_GETCOUNT, 0, 0);
23                _tprintf(_T("CPL_GETCOUNT: %d applets\n"), nResult);
24                const INT nAppletIndex = 0;
25                _tprintf(_T("nAppletIndex: %d\n"), nAppletIndex);
26                #pragma region CPL_INQUIRE
27                CPLINFO Information;
28                ZeroMemory(&Information, sizeof Information);
29                nResult = pCplApplet(GetActiveWindow(), CPL_INQUIRE, nAppletIndex, (LPARAM) &Information);
30                if(!nResult)
31                        _tprintf(_T("CPL_INQUIRE: .idIcon %d, .idName %d, .idInfo %d, .lData 0x%p\n"), Information.idIcon, Information.idName, Information.idInfo, Information.lData);
32                else
33                        _tprintf(_T("CPL_INQUIRE: %d\n"), nResult);
34                #pragma endregion
35                #pragma region CPL_NEWINQUIRE
36                NEWCPLINFO NewInformation;
37                ZeroMemory(&NewInformation, sizeof NewInformation);
38                NewInformation.dwSize = sizeof NewInformation;
39                nResult = pCplApplet(GetActiveWindow(), CPL_NEWINQUIRE, nAppletIndex, (LPARAM) &NewInformation);
40                if(!nResult)
41                        _tprintf(_T("CPL_NEWINQUIRE: .dwFlags 0x%x, .szName \"%s\", .szInfo \"%s\"\n"), NewInformation.dwFlags, NewInformation.szName, NewInformation.szInfo);
42                else
43                        _tprintf(_T("CPL_NEWINQUIRE: %d\n"), nResult);
44                #pragma endregion
45                OSVERSIONINFOEX VersionInformation = { sizeof VersionInformation };
46                GetVersionEx((OSVERSIONINFO*) &VersionInformation);
47                _tprintf(_T("GetVersionEx: %d.%d\n"), VersionInformation.dwMajorVersion, VersionInformation.dwMinorVersion);
48                if(VersionInformation.dwMajorVersion >= 6)
49                {
50                        LPCTSTR g_pszParameters = _T("recording");
51                        pCplApplet(GetActiveWindow(), CPL_STARTWPARMS, nAppletIndex, (LPARAM) g_pszParameters);
52                } else
53                {
54                        //HINSTANCE hModule = LoadLibrary(_T("shell32.dll"));
55                        //typedef VOID (CALLBACK *CONTROL_RUNDLL)(HWND hParentWinow, HINSTANCE hInstance, LPWSTR pszCommandLine, INT nShowCommand);
56                        //CONTROL_RUNDLL pControlRunDll = (CONTROL_RUNDLL)GetProcAddress(hModule, "Control_RunDLLW");
57                        //pControlRunDll(GetActiveWindow(), NULL, _T("mmsys.cpl,,2"), SW_SHOWNORMAL);
58                        pCplApplet(GetActiveWindow(), CPL_DBLCLK, nAppletIndex, (LPARAM) Information.lData);
59                }
60                pCplApplet(GetActiveWindow(), CPL_EXIT, 0, 0);
61        } else
62                _tprintf(_T("CPL_INIT Failure: %d\n"), nResult);
63        return 0;
64}
65
Note: See TracBrowser for help on using the repository browser.