ReactOS 0.4.15-dev-7842-g558ab78
hardprof.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for hardprof.c:

Go to the source code of this file.

Classes

struct  _PROFILE
 
struct  _PROFILEDATA
 
struct  _PROFILENAMES
 

Macros

#define PROFILE_NAME_LENGTH   80
 

Typedefs

typedef struct _PROFILE PROFILE
 
typedef struct _PROFILEPPROFILE
 
typedef struct _PROFILEDATA PROFILEDATA
 
typedef struct _PROFILEDATAPPROFILEDATA
 
typedef struct _PROFILENAMES PROFILENAMES
 
typedef struct _PROFILENAMESPPROFILENAMES
 

Functions

static VOID UpdateButtons (HWND hwndDlg, PPROFILEDATA pProfileData)
 
static BOOL IsProfileNameInUse (PPROFILENAMES pProfileNames, BOOL bIgnoreCurrent)
 
static INT_PTR CALLBACK CopyProfileDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID CopyHardwareProfile (HWND hwndDlg, PPROFILEDATA pProfileData)
 
static INT_PTR CALLBACK RenameProfileDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID RenameHardwareProfile (HWND hwndDlg, PPROFILEDATA pProfileData)
 
static VOID DeleteHardwareProfile (HWND hwndDlg, PPROFILEDATA pProfileData)
 
static VOID MoveHardwareProfile (HWND hwndDlg, PPROFILEDATA pProfileData, BOOL bMoveUp)
 
static INT_PTR CALLBACK HardwareProfilePropertiesDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
static VOID HardwareProfileProperties (HWND hwndDlg, PPROFILEDATA pProfileData)
 
static DWORD GetUserWaitInterval (VOID)
 
static VOID SetUserWaitInterval (DWORD dwWaitInterval)
 
static BOOL GetProfileCount (LPDWORD lpProfileCount)
 
static VOID GetProfile (HWND hwndDlg, HKEY hKey, LPWSTR lpName, DWORD dwProfileNumber, PPROFILE pProfile)
 
static BOOL GetProfiles (HWND hwndDlg)
 
static BOOL OnInitHardProfDialog (HWND hwndDlg)
 
static VOID OnOk (HWND hwndDlg)
 
INT_PTR CALLBACK HardProfDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ PROFILE_NAME_LENGTH

#define PROFILE_NAME_LENGTH   80

Definition at line 14 of file hardprof.c.

Typedef Documentation

◆ PPROFILE

◆ PPROFILEDATA

◆ PPROFILENAMES

◆ PROFILE

◆ PROFILEDATA

◆ PROFILENAMES

Function Documentation

◆ CopyHardwareProfile()

static VOID CopyHardwareProfile ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 150 of file hardprof.c.

153{
154 PROFILENAMES ProfileNames;
155 PPROFILE pProfile, pNewProfiles, pNewProfile;
156 WCHAR szBuffer[80];
157
158 pProfile = &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex];
159
160 LoadStringW(hApplet, IDS_HWPROFILE_PROFILE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR));
161
162 wcscpy(ProfileNames.szSourceName, pProfile->szFriendlyName);
163 swprintf(ProfileNames.szDestinationName, L"%s %lu", szBuffer, pProfileData->dwProfileCount);
164
165 ProfileNames.pProfileData = pProfileData;
166
169 hwndDlg,
171 (LPARAM)&ProfileNames) != IDOK)
172 return;
173
174 /* Apply new name only if it has been changed */
175 if (wcscmp(ProfileNames.szSourceName, ProfileNames.szDestinationName) == 0)
176 return;
177
178 /* Allocate memory for the new profile */
179 pNewProfiles = HeapReAlloc(GetProcessHeap(),
181 pProfileData->pProfiles,
182 (pProfileData->dwProfileCount + 1) * sizeof(PROFILE));
183 if (pNewProfiles == NULL)
184 {
185 DPRINT1("HeapReAlloc() failed!\n");
186 return;
187 }
188
189 pProfileData->dwProfileCount++;
190 pProfileData->pProfiles = pNewProfiles;
191
192 pNewProfile = &pProfileData->pProfiles[pProfileData->dwProfileCount - 1];
193
194 CopyMemory(pNewProfile, pProfile, sizeof(PROFILE));
195
196 wcscpy(pNewProfile->szFriendlyName, ProfileNames.szDestinationName);
197
198 pNewProfile->dwProfileNumber = ++pProfileData->dwLastProfile;
199 swprintf(pNewProfile->szName, L"%04lu", pNewProfile->dwProfileNumber);
200
201 pNewProfile->dwPreferenceOrder = pNewProfile->dwProfileNumber;
202
204
205 UpdateButtons(hwndDlg, pProfileData);
206}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
HINSTANCE hApplet
Definition: access.c:17
#define IDD_COPYPROFILE
Definition: resource.h:215
#define IDS_HWPROFILE_PROFILE
Definition: resource.h:59
#define IDC_HRDPROFLSTBOX
Definition: resource.h:191
#define GetProcessHeap()
Definition: compat.h:736
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define swprintf
Definition: precomp.h:40
static INT_PTR CALLBACK CopyProfileDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hardprof.c:91
static VOID UpdateButtons(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: hardprof.c:43
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PPROFILE pProfiles
Definition: hardprof.c:30
DWORD dwLastProfile
Definition: hardprof.c:27
DWORD dwProfileCount
Definition: hardprof.c:26
DWORD dwSelectedProfileIndex
Definition: hardprof.c:29
WCHAR szDestinationName[PROFILE_NAME_LENGTH]
Definition: hardprof.c:36
PPROFILEDATA pProfileData
Definition: hardprof.c:37
WCHAR szSourceName[PROFILE_NAME_LENGTH]
Definition: hardprof.c:35
WCHAR szName[5]
Definition: hardprof.c:19
DWORD dwProfileNumber
Definition: hardprof.c:20
DWORD dwPreferenceOrder
Definition: hardprof.c:21
WCHAR szFriendlyName[PROFILE_NAME_LENGTH]
Definition: hardprof.c:18
#define CopyMemory
Definition: winbase.h:1710
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DialogBoxParam
Definition: winuser.h:5764
#define LB_ADDSTRING
Definition: winuser.h:2031
#define IDOK
Definition: winuser.h:830
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAKEINTRESOURCE
Definition: winuser.h:591
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HardProfDlgProc().

◆ CopyProfileDlgProc()

static INT_PTR CALLBACK CopyProfileDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 91 of file hardprof.c.

96{
97 PPROFILENAMES pProfileNames;
98
99 pProfileNames = (PPROFILENAMES)GetWindowLongPtr(hwndDlg, DWLP_USER);
100
101 switch (uMsg)
102 {
103 case WM_INITDIALOG:
105 pProfileNames = (PPROFILENAMES)lParam;
106
107 /* Set the old name */
108 SetDlgItemText(hwndDlg, IDC_COPYPROFILEFROM, pProfileNames->szSourceName);
109
110 /* Set the new name */
112 SetDlgItemText(hwndDlg, IDC_COPYPROFILETO, pProfileNames->szDestinationName);
113 break;
114
115 case WM_COMMAND:
116 switch (LOWORD(wParam))
117 {
118 case IDOK:
119 GetDlgItemText(hwndDlg,
121 pProfileNames->szDestinationName,
123 if (IsProfileNameInUse(pProfileNames, FALSE))
124 {
126 hwndDlg,
130 }
131 else
132 {
133 EndDialog(hwndDlg, IDOK);
134 }
135 return TRUE;
136
137 case IDCANCEL:
138 EndDialog(hwndDlg, IDCANCEL);
139 return TRUE;
140 }
141 break;
142 }
143
144 return FALSE;
145}
VOID ResourceMessageBox(HINSTANCE hInstance, HWND hwnd, UINT uType, UINT uCaptionId, UINT uMessageId)
Definition: misc.c:282
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_HWPROFILE_WARNING
Definition: resource.h:60
#define IDC_COPYPROFILEFROM
Definition: resource.h:216
#define IDC_COPYPROFILETO
Definition: resource.h:217
#define IDS_HWPROFILE_ALREADY_IN_USE
Definition: resource.h:58
struct _PROFILENAMES * PPROFILENAMES
#define PROFILE_NAME_LENGTH
Definition: hardprof.c:14
static BOOL IsProfileNameInUse(PPROFILENAMES pProfileNames, BOOL bIgnoreCurrent)
Definition: hardprof.c:69
#define LOWORD(l)
Definition: pedump.c:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWLP_USER
Definition: winuser.h:872
#define IDCANCEL
Definition: winuser.h:831
#define GetDlgItemText
Definition: winuser.h:5785
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define MB_ICONERROR
Definition: winuser.h:787
#define EM_SETLIMITTEXT
Definition: winuser.h:2011
#define MB_OK
Definition: winuser.h:790
#define SetDlgItemText
Definition: winuser.h:5849
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by CopyHardwareProfile().

◆ DeleteHardwareProfile()

static VOID DeleteHardwareProfile ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 310 of file hardprof.c.

313{
314 PPROFILE pProfiles;
315 PPROFILE pProfile;
316
317 pProfile = &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex];
318
320 hwndDlg,
324 pProfile->szFriendlyName) != IDYES)
325 {
326 return;
327 }
328
330
331 if (pProfileData->dwSelectedProfileIndex != pProfileData->dwProfileCount - 1)
332 {
333 RtlMoveMemory(&pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex],
334 &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex + 1],
335 (pProfileData->dwProfileCount - pProfileData->dwSelectedProfileIndex - 1) * sizeof(PROFILE));
336 }
337 else
338 {
339 pProfileData->dwSelectedProfileIndex--;
340 }
341
342 pProfiles = HeapReAlloc(GetProcessHeap(),
344 pProfileData->pProfiles,
345 (pProfileData->dwProfileCount - 1) * sizeof(PROFILE));
346 if (pProfiles == NULL)
347 {
348 DPRINT1("HeapReAlloc() failed!\n");
349 return;
350 }
351
352 pProfileData->dwProfileCount--;
353 pProfileData->pProfiles = pProfiles;
354
356
357 UpdateButtons(hwndDlg, pProfileData);
358}
#define IDS_HWPROFILE_CONFIRM_DELETE_TITLE
Definition: resource.h:56
#define IDS_HWPROFILE_CONFIRM_DELETE
Definition: resource.h:57
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define MB_YESNO
Definition: winuser.h:817
#define LB_DELETESTRING
Definition: winuser.h:2032
#define MB_ICONQUESTION
Definition: winuser.h:789
#define LB_SETCURSEL
Definition: winuser.h:2063
#define IDYES
Definition: winuser.h:835

Referenced by HardProfDlgProc().

◆ GetProfile()

static VOID GetProfile ( HWND  hwndDlg,
HKEY  hKey,
LPWSTR  lpName,
DWORD  dwProfileNumber,
PPROFILE  pProfile 
)
static

Definition at line 555 of file hardprof.c.

561{
562 HKEY hProfileKey;
564 LONG lError;
565
566 lError = RegOpenKeyExW(hKey,
567 lpName,
568 0,
569 KEY_READ,
570 &hProfileKey);
571 if (lError != ERROR_SUCCESS)
572 return;
573
574 dwSize = PROFILE_NAME_LENGTH * sizeof(WCHAR);
575 lError = RegQueryValueExW(hProfileKey,
576 L"FriendlyName",
577 NULL,
578 NULL,
579 (LPBYTE)pProfile->szFriendlyName,
580 &dwSize);
581 if (lError == ERROR_SUCCESS)
582 {
583 DPRINT1("Profile: %S\n", pProfile->szFriendlyName);
584 }
585
586 dwSize = sizeof(DWORD);
587 lError = RegQueryValueExW(hProfileKey,
588 L"PreferenceOrder",
589 NULL,
590 NULL,
591 (LPBYTE)&pProfile->dwPreferenceOrder,
592 &dwSize);
593 if (lError == ERROR_SUCCESS)
594 {
595 DPRINT1("PreferenceOrder: %lu\n", pProfile->dwPreferenceOrder);
596 }
597
598 pProfile->dwProfileNumber = dwProfileNumber;
599
601
602 RegCloseKey(hProfileKey);
603}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
unsigned char * LPBYTE
Definition: typedefs.h:53
_In_ LPCSTR lpName
Definition: winbase.h:2789

Referenced by GetProfiles().

◆ GetProfileCount()

static BOOL GetProfileCount ( LPDWORD  lpProfileCount)
static

Definition at line 526 of file hardprof.c.

527{
528 HKEY hKey;
529 LONG lError;
530
531 *lpProfileCount = 0;
532
534 L"System\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles",
535 0,
536 KEY_READ,
537 &hKey);
538 if (lError != ERROR_SUCCESS)
539 return FALSE;
540
541 lError = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, lpProfileCount,
542 NULL, NULL, NULL, NULL, NULL, NULL, NULL);
543
545
546 if (lError != ERROR_SUCCESS)
547 return FALSE;
548
549 return TRUE;
550}
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetProfiles().

◆ GetProfiles()

static BOOL GetProfiles ( HWND  hwndDlg)
static

Definition at line 608 of file hardprof.c.

609{
610 PPROFILEDATA pProfileData;
611 WCHAR szName[8];
612 DWORD dwNameLength;
613 DWORD dwProfileNumber;
614 DWORD dwIndex = 0;
615 HKEY hKey;
616 LONG lError;
617
618 pProfileData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PROFILEDATA));
619 if (pProfileData == NULL)
620 return FALSE;
621
622 pProfileData->dwLastProfile = (DWORD)-1;
623 pProfileData->dwSelectedProfileIndex = (DWORD)-1;
624
625 if (!GetProfileCount(&pProfileData->dwProfileCount))
626 {
627 HeapFree(GetProcessHeap(), 0, pProfileData);
628 return FALSE;
629 }
630
632 pProfileData->dwProfileCount * sizeof(PROFILE));
633 if (pProfileData->pProfiles == NULL)
634 {
635 HeapFree(GetProcessHeap(), 0, pProfileData);
636 return FALSE;
637 }
638
639 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pProfileData);
640
642 L"System\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles",
643 0,
644 KEY_READ,
645 &hKey) != ERROR_SUCCESS)
646 return FALSE;
647
648 for (dwIndex = 0; dwIndex < pProfileData->dwProfileCount; dwIndex++)
649 {
650 dwNameLength = 8;
651 lError = RegEnumKeyExW(hKey,
652 dwIndex,
653 szName,
654 &dwNameLength,
655 NULL,
656 NULL,
657 NULL,
658 NULL);
659 if (lError != ERROR_SUCCESS)
660 break;
661
662 dwProfileNumber = wcstoul(szName, NULL, 10);
663 DPRINT("Profile name: %S\n", szName);
664 DPRINT("Profile number: %lu\n", dwProfileNumber);
665
666 if ((pProfileData->dwLastProfile == (DWORD)-1) ||
667 (pProfileData->dwLastProfile < dwProfileNumber))
668 pProfileData->dwLastProfile = dwProfileNumber;
669
670 DPRINT("Last Profile number: %lu\n", pProfileData->dwLastProfile);
671
672 GetProfile(hwndDlg, hKey, szName, dwProfileNumber, &pProfileData->pProfiles[dwIndex]);
673 }
674
676
677 return TRUE;
678}
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static BOOL GetProfileCount(LPDWORD lpProfileCount)
Definition: hardprof.c:526
static VOID GetProfile(HWND hwndDlg, HKEY hKey, LPWSTR lpName, DWORD dwProfileNumber, PPROFILE pProfile)
Definition: hardprof.c:555
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static const WCHAR szName[]
Definition: powrprof.c:45
#define DPRINT
Definition: sndvol32.h:71

Referenced by OnInitHardProfDialog().

◆ GetUserWaitInterval()

static DWORD GetUserWaitInterval ( VOID  )
static

Definition at line 473 of file hardprof.c.

474{
475 DWORD dwWaitInterval = 30;
477 HKEY hKey;
478
480 L"System\\CurrentControlSet\\Control\\IDConfigDB",
481 0,
483 &hKey))
484 return dwWaitInterval;
485
486 dwSize = sizeof(DWORD);
488 L"UserWaitInterval",
489 NULL,
490 NULL,
491 (LPBYTE)&dwWaitInterval,
492 &dwSize);
493
495
496 return dwWaitInterval;
497}
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016

Referenced by OnInitHardProfDialog().

◆ HardProfDlgProc()

INT_PTR CALLBACK HardProfDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 740 of file hardprof.c.

744{
745 PPROFILEDATA pProfileData;
746
749 UNREFERENCED_PARAMETER(hwndDlg);
750
751 pProfileData = (PPROFILEDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
752
753 switch (uMsg)
754 {
755 case WM_INITDIALOG:
756 return OnInitHardProfDialog(hwndDlg);
757
758 case WM_DESTROY:
759 if (pProfileData != NULL)
760 {
761 if (pProfileData->pProfiles != NULL)
762 HeapFree(GetProcessHeap(), 0, pProfileData->pProfiles);
763 HeapFree(GetProcessHeap(), 0, pProfileData);
764 }
765 break;
766
767 case WM_COMMAND:
768 switch (LOWORD(wParam))
769 {
770 case IDC_HRDPROFPROP:
771 HardwareProfileProperties(hwndDlg, pProfileData);
772 break;
773
774 case IDC_HRDPROFCOPY:
775 CopyHardwareProfile(hwndDlg, pProfileData);
776 break;
777
779 RenameHardwareProfile(hwndDlg, pProfileData);
780 break;
781
782 case IDC_HRDPROFDEL:
783 DeleteHardwareProfile(hwndDlg, pProfileData);
784 break;
785
786 case IDC_HRDPROFUP:
787 MoveHardwareProfile(hwndDlg, pProfileData, TRUE);
788 break;
789
790 case IDC_HRDPROFDWN:
791 MoveHardwareProfile(hwndDlg, pProfileData, FALSE);
792 break;
793
794 case IDC_HRDPROFWAIT:
796 return TRUE;
797
800 return TRUE;
801
804 {
806 UpdateButtons(hwndDlg, pProfileData);
807 }
808 return TRUE;
809
810 case IDOK:
811 OnOk(hwndDlg);
812
813 case IDCANCEL:
814 EndDialog(hwndDlg, LOWORD(wParam));
815 return TRUE;
816 }
817 break;
818 }
819
820 return FALSE;
821}
#define IDC_HRDPROFDWN
Definition: resource.h:193
#define IDC_HRDPROFCOPY
Definition: resource.h:195
#define IDC_HRDPROFRENAME
Definition: resource.h:196
#define IDC_HRDPROFUP
Definition: resource.h:192
#define IDC_HRDPROFEDIT
Definition: resource.h:200
#define IDC_HRDPROFSELECT
Definition: resource.h:199
#define IDC_HRDPROFDEL
Definition: resource.h:197
#define IDC_HRDPROFWAIT
Definition: resource.h:198
#define IDC_HRDPROFPROP
Definition: resource.h:194
static VOID HardwareProfileProperties(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: hardprof.c:434
static VOID CopyHardwareProfile(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: hardprof.c:150
static BOOL OnInitHardProfDialog(HWND hwndDlg)
Definition: hardprof.c:683
struct _PROFILEDATA * PPROFILEDATA
static VOID OnOk(HWND hwndDlg)
Definition: hardprof.c:720
static VOID MoveHardwareProfile(HWND hwndDlg, PPROFILEDATA pProfileData, BOOL bMoveUp)
Definition: hardprof.c:363
static VOID DeleteHardwareProfile(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: hardprof.c:310
static VOID RenameHardwareProfile(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: hardprof.c:271
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define HIWORD(l)
Definition: typedefs.h:247
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LBN_SELCHANGE
Definition: winuser.h:2075
#define WM_DESTROY
Definition: winuser.h:1609
#define LB_GETCURSEL
Definition: winuser.h:2039
#define SendDlgItemMessage
Definition: winuser.h:5842

Referenced by HardwarePageProc().

◆ HardwareProfileProperties()

static VOID HardwareProfileProperties ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 434 of file hardprof.c.

437{
438 HPROPSHEETPAGE hpsp;
439 PROPSHEETHEADER psh;
440 PROPSHEETPAGE psp;
441
442 ZeroMemory(&psp, sizeof(psp));
443 psp.dwSize = sizeof(psp);
444 psp.dwFlags = PSP_DEFAULT;
445 psp.hInstance = hApplet;
446 psp.pszTemplate = MAKEINTRESOURCE(IDD_HARDWAREPROFILE);
447 psp.pfnDlgProc = HardwareProfilePropertiesDlgProc;
448
449 hpsp = CreatePropertySheetPage(&psp);
450 if (hpsp == NULL)
451 {
452 return;
453 }
454
455 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
456 psh.dwSize = sizeof(PROPSHEETHEADER);
458 psh.hwndParent = hwndDlg;
459 psh.hInstance = hApplet;
460 psh.pszIcon = MAKEINTRESOURCEW(IDI_HARDPROF);
461 psh.pszCaption = pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex].szFriendlyName;
462 psh.nPages = 1;
463 psh.nStartPage = 0;
464 psh.phpage = &hpsp;
465 psh.pfnCallback = PropSheetProc;
466
467 PropertySheet(&psh);
468}
#define IDD_HARDWAREPROFILE
Definition: resource.h:204
#define IDI_HARDPROF
Definition: resource.h:7
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: hardprof.c:416
static INT_PTR CALLBACK HardwareProfilePropertiesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hardprof.c:395
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_PROPTITLE
Definition: prsht.h:40
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropertySheet
Definition: prsht.h:400
#define PSH_USEICONID
Definition: prsht.h:42
#define PROPSHEETPAGE
Definition: prsht.h:389
#define ZeroMemory
Definition: winbase.h:1712
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by HardProfDlgProc().

◆ HardwareProfilePropertiesDlgProc()

static INT_PTR CALLBACK HardwareProfilePropertiesDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 395 of file hardprof.c.

400{
401 UNREFERENCED_PARAMETER(hwndDlg);
404
405 switch (uMsg)
406 {
407 case WM_INITDIALOG:
408 return TRUE;
409
410 }
411
412 return FALSE;
413}

Referenced by HardwareProfileProperties().

◆ IsProfileNameInUse()

static BOOL IsProfileNameInUse ( PPROFILENAMES  pProfileNames,
BOOL  bIgnoreCurrent 
)
static

Definition at line 69 of file hardprof.c.

72{
73 DWORD i;
74
75 for (i = 0; i < pProfileNames->pProfileData->dwProfileCount; i++)
76 {
77 if (bIgnoreCurrent == TRUE && i == pProfileNames->pProfileData->dwSelectedProfileIndex)
78 continue;
79
80 if (wcscmp(pProfileNames->pProfileData->pProfiles[i].szFriendlyName, pProfileNames->szDestinationName) == 0)
81 return TRUE;
82 }
83
84 return FALSE;
85}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by CopyProfileDlgProc(), and RenameProfileDlgProc().

◆ MoveHardwareProfile()

static VOID MoveHardwareProfile ( HWND  hwndDlg,
PPROFILEDATA  pProfileData,
BOOL  bMoveUp 
)
static

Definition at line 363 of file hardprof.c.

367{
368 PROFILE TempProfile;
369 PPROFILE pSrcProfile, pDstProfile;
370 DWORD dwSrcIndex, dwDstIndex;
371
372 dwSrcIndex = pProfileData->dwSelectedProfileIndex;
373 dwDstIndex = bMoveUp ? (dwSrcIndex - 1) : (dwSrcIndex + 1);
374
375 pSrcProfile = &pProfileData->pProfiles[dwSrcIndex];
376 pDstProfile = &pProfileData->pProfiles[dwDstIndex];
377
378 CopyMemory(&TempProfile, pDstProfile, sizeof(PROFILE));
379 CopyMemory(pDstProfile, pSrcProfile, sizeof(PROFILE));
380 CopyMemory(pSrcProfile, &TempProfile, sizeof(PROFILE));
381
382 SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, dwSrcIndex, 0);
383 SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_INSERTSTRING, dwDstIndex, (LPARAM)pDstProfile->szFriendlyName);
384
385 pProfileData->dwSelectedProfileIndex = dwDstIndex;
387
388 UpdateButtons(hwndDlg, pProfileData);
389}
#define LB_INSERTSTRING
Definition: winuser.h:2053

Referenced by HardProfDlgProc().

◆ OnInitHardProfDialog()

static BOOL OnInitHardProfDialog ( HWND  hwndDlg)
static

Definition at line 683 of file hardprof.c.

684{
685 DWORD dwWaitInterval;
686
687 DPRINT("OnInitHardProfDialog()\n");
688
695
696 if (!GetProfiles(hwndDlg))
697 return FALSE;
698
700
701 dwWaitInterval = GetUserWaitInterval();
702 if (dwWaitInterval == (DWORD)-1)
703 {
707 }
708 else
709 {
711 SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETPOS, 0, dwWaitInterval);
712 }
713
714 return TRUE;
715}
#define IDI_DOWN
Definition: resource.h:11
#define IDI_UP
Definition: resource.h:10
#define IDC_HRDPROFUPDWN
Definition: resource.h:201
static BOOL GetProfiles(HWND hwndDlg)
Definition: hardprof.c:608
static DWORD GetUserWaitInterval(VOID)
Definition: hardprof.c:473
short SHORT
Definition: pedump.c:59
#define UDM_SETPOS
Definition: commctrl.h:2143
#define UDM_SETRANGE
Definition: commctrl.h:2141
#define MAKELONG(a, b)
Definition: typedefs.h:249
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IMAGE_ICON
Definition: winuser.h:212
#define BM_SETIMAGE
Definition: winuser.h:1922
#define LoadIcon
Definition: winuser.h:5813
#define SendMessage
Definition: winuser.h:5843
#define BST_CHECKED
Definition: winuser.h:197

Referenced by HardProfDlgProc().

◆ OnOk()

static VOID OnOk ( HWND  hwndDlg)
static

Definition at line 720 of file hardprof.c.

721{
722 DWORD dwWaitInterval;
723
725 {
726 dwWaitInterval = (DWORD)-1;
727 }
728 else
729 {
730 dwWaitInterval = LOWORD(SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_GETPOS, 0, 0));
731 }
732
733 SetUserWaitInterval(dwWaitInterval);
734}
static VOID SetUserWaitInterval(DWORD dwWaitInterval)
Definition: hardprof.c:502
#define UDM_GETPOS
Definition: commctrl.h:2144
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)

Referenced by HardProfDlgProc().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 416 of file hardprof.c.

417{
418 // NOTE: This callback is needed to set large icon correctly.
419 HICON hIcon;
420 switch (uMsg)
421 {
422 case PSCB_INITIALIZED:
423 {
425 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
426 break;
427 }
428 }
429 return 0;
430}
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define ICON_BIG
Definition: tnclass.cpp:51
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by HardwareProfileProperties().

◆ RenameHardwareProfile()

static VOID RenameHardwareProfile ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 271 of file hardprof.c.

274{
275 PROFILENAMES ProfileNames;
276 PPROFILE pProfile;
277 WCHAR szBuffer[80];
278
279 pProfile = &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex];
280
281 LoadStringW(hApplet, IDS_HWPROFILE_PROFILE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR));
282
283 wcscpy(ProfileNames.szSourceName, pProfile->szFriendlyName);
284 swprintf(ProfileNames.szDestinationName, L"%s %lu", szBuffer, pProfileData->dwProfileCount);
285
286 ProfileNames.pProfileData = pProfileData;
287
290 hwndDlg,
292 (LPARAM)&ProfileNames) != IDOK)
293 return;
294
295 /* Apply new name only if it has been changed */
296 if (wcscmp(pProfile->szFriendlyName, ProfileNames.szDestinationName) == 0)
297 return;
298
299 /* Replace the profile name in the profile list */
300 wcscpy(pProfile->szFriendlyName, ProfileNames.szDestinationName);
301
302 /* Replace the profile name in the listbox */
305}
#define IDD_RENAMEPROFILE
Definition: resource.h:220
static INT_PTR CALLBACK RenameProfileDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hardprof.c:212

Referenced by HardProfDlgProc().

◆ RenameProfileDlgProc()

static INT_PTR CALLBACK RenameProfileDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 212 of file hardprof.c.

217{
218 PPROFILENAMES pProfileNames;
219
220 pProfileNames = (PPROFILENAMES)GetWindowLongPtr(hwndDlg, DWLP_USER);
221
222 switch (uMsg)
223 {
224 case WM_INITDIALOG:
226 pProfileNames = (PPROFILENAMES)lParam;
227
228 /* Set the old name */
229 SetDlgItemText(hwndDlg, IDC_RENPROFEDITFROM, pProfileNames->szSourceName);
230
231 /* Set the new name */
233 SetDlgItemText(hwndDlg, IDC_RENPROFEDITTO, pProfileNames->szDestinationName);
234 break;
235
236 case WM_COMMAND:
237 switch (LOWORD(wParam))
238 {
239 case IDOK:
240 GetDlgItemText(hwndDlg,
242 pProfileNames->szDestinationName,
244 if (IsProfileNameInUse(pProfileNames, TRUE))
245 {
247 hwndDlg,
251 }
252 else
253 {
254 EndDialog(hwndDlg, IDOK);
255 }
256 return TRUE;
257
258 case IDCANCEL:
259 EndDialog(hwndDlg, IDCANCEL);
260 return TRUE;
261 }
262 break;
263 }
264
265 return FALSE;
266}
#define IDC_RENPROFEDITTO
Definition: resource.h:222
#define IDC_RENPROFEDITFROM
Definition: resource.h:221

Referenced by RenameHardwareProfile().

◆ SetUserWaitInterval()

static VOID SetUserWaitInterval ( DWORD  dwWaitInterval)
static

Definition at line 502 of file hardprof.c.

503{
504 HKEY hKey;
505
507 L"System\\CurrentControlSet\\Control\\IDConfigDB",
508 0,
510 &hKey))
511 return;
512
514 L"UserWaitInterval",
515 0,
516 REG_DWORD,
517 (LPBYTE)&dwWaitInterval,
518 sizeof(DWORD));
519
521}
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by OnOk().

◆ UpdateButtons()

static VOID UpdateButtons ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 43 of file hardprof.c.

46{
47 EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFPROP), (pProfileData->dwSelectedProfileIndex != (DWORD)-1) ? TRUE : FALSE);
48 EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFCOPY), (pProfileData->dwSelectedProfileIndex != (DWORD)-1) ? TRUE : FALSE);
49 EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFRENAME), (pProfileData->dwSelectedProfileIndex != (DWORD)-1) ? TRUE : FALSE);
50 EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFDEL), (pProfileData->dwSelectedProfileIndex != (DWORD)-1) ? TRUE : FALSE);
51
52 if (pProfileData->dwProfileCount < 2)
53 {
56 }
57 else
58 {
60 (pProfileData->dwSelectedProfileIndex > 0) ? TRUE : FALSE);
62 (pProfileData->dwSelectedProfileIndex < pProfileData->dwProfileCount - 1) ? TRUE : FALSE);
63 }
64}

Referenced by CopyHardwareProfile(), DeleteHardwareProfile(), HardProfDlgProc(), and MoveHardwareProfile().