Skip to content

Latest commit

 

History

History
131 lines (96 loc) · 4.89 KB

nf-winbase-getcurrenthwprofilew.md

File metadata and controls

131 lines (96 loc) · 4.89 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:winbase.GetCurrentHwProfileW
GetCurrentHwProfileW function (winbase.h)
Retrieves information about the current hardware profile for the local computer. (Unicode)
GetCurrentHwProfile
GetCurrentHwProfile function
GetCurrentHwProfileW
_win32_getcurrenthwprofile
base.getcurrenthwprofile
winbase/GetCurrentHwProfile
winbase/GetCurrentHwProfileW
base\getcurrenthwprofile.htm
winprog
152067bb-3896-43ef-a882-12a159f92cc7
12/05/2018
GetCurrentHwProfile, GetCurrentHwProfile function, GetCurrentHwProfileA, GetCurrentHwProfileW, _win32_getcurrenthwprofile, base.getcurrenthwprofile, winbase/GetCurrentHwProfile, winbase/GetCurrentHwProfileA, winbase/GetCurrentHwProfileW
winbase.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
GetCurrentHwProfileW (Unicode) and GetCurrentHwProfileA (ANSI)
Advapi32.lib
Advapi32.dll
Windows
19H1
GetCurrentHwProfileW
winbase/GetCurrentHwProfileW
c++
APIRef
kbSyntax
DllExport
Advapi32.dll
Ext-MS-Win-AdvAPI32-hwprof-l1-1-0.dll
GetCurrentHwProfile
GetCurrentHwProfileA
GetCurrentHwProfileW
ext-ms-win-advapi32-hwprof-l1-1-0 (introduced in Windows 10, version 10.0.10240)

GetCurrentHwProfileW function

-description

Retrieves information about the current hardware profile for the local computer.

-parameters

-param lpHwProfileInfo [out]

A pointer to an HW_PROFILE_INFO structure that receives information about the current hardware profile.

-returns

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

-remarks

The GetCurrentHwProfile function retrieves the display name and globally unique identifier (GUID) string for the hardware profile. The function also retrieves the reported docking state for portable computers with docking stations.

The system generates a GUID for each hardware profile and stores it as a string in the registry. You can use GetCurrentHwProfile to retrieve the GUID string to use as a registry subkey under your application's configuration settings key in HKEY_CURRENT_USER. This enables you to store each user's settings for each hardware profile. For example, the Colors control panel application could use the subkey to store each user's color preferences for different hardware profiles, such as profiles for the docked and undocked states. Applications that use this functionality can check the current hardware profile when they start up, and update their settings accordingly.

Applications can also update their settings when a system device message, such as DBT_CONFIGCHANGED, indicates that the hardware profile has changed.

To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the Windows Headers.

Examples

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

void main(void) 
{
   HW_PROFILE_INFO   HwProfInfo;
   if (!GetCurrentHwProfile(&HwProfInfo)) 
   {
      _tprintf(TEXT("GetCurrentHwProfile failed with error %lx\n"), 
                 GetLastError());
      return;
   }
   _tprintf(TEXT("DockInfo = %d\n"), HwProfInfo.dwDockInfo);
   _tprintf(TEXT("Profile Guid = %s\n"), HwProfInfo.szHwProfileGuid);
   _tprintf(TEXT("Friendly Name = %s\n"), HwProfInfo.szHwProfileName);
}

Note

The winbase.h header defines GetCurrentHwProfile as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

DBT_CONFIGCHANGED

HW_PROFILE_INFO

System Information Functions