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 | |
---|
11 | int _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 | if(VersionInformation.dwMajorVersion >= 6) |
---|
48 | { |
---|
49 | LPCTSTR g_pszParameters = _T("recording"); |
---|
50 | pCplApplet(GetActiveWindow(), CPL_STARTWPARMS, nAppletIndex, (LPARAM) g_pszParameters); |
---|
51 | } else |
---|
52 | pCplApplet(GetActiveWindow(), CPL_DBLCLK, nAppletIndex, 2); |
---|
53 | pCplApplet(GetActiveWindow(), CPL_EXIT, 0, 0); |
---|
54 | } else |
---|
55 | _tprintf(_T("CPL_INIT Failure: %d\n"), nResult); |
---|
56 | return 0; |
---|
57 | } |
---|
58 | |
---|