SetProcessDPIAware function

Expand
1 out of 10 rated this helpful - Rate this topic

SetProcessDPIAware function

Applies to: desktop apps only

Sets the current process as dots per inch (dpi) aware.

Note  SetProcessDPIAware is subject to a possible race condition if a DLL caches dpi settings during initialization. For this reason, it is recommended that dpi-aware be set through the application (.exe) manifest rather than by calling SetProcessDPIAware.

Syntax

BOOL WINAPI SetProcessDPIAware(void);

Parameters

This function has no parameters.

Return value

Type:

Type: BOOL

If the function succeeds, the return value is nonzero. Otherwise, the return value is zero.

Remarks

DLLs should accept the dpi setting of the host process rather than call SetProcessDPIAware themselves. To be set properly, dpiAware should be specified as part of the application (.exe) manifest. (dpiAware defined in an embedded DLL manifest has no affect.) The following markup shows how to set dpiAware as part of an application (.exe) manifest.


<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
 ...
  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
 ...
</assembly>

For more information about application manifests, see Manifests (Side-by-Side Assemblies).

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

 

 

Send comments about this topic to Microsoft

Build date: 5/5/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD
Merging two manifest is not creating valid manifest
I ran in to issue while merging DPIAware manifest to my existing application manifest. when running the command::::::::::::: C:\ssaxena_view\ucc\Source\UCCClient\Aspect.UCC.SmartClient.Shell\bin\debug>mt.exe -manifest Aspect.UCC.SmartClient.Shell.exe.manifest DeclareDPIAware .manifest -out:Final.manifest Microsoft (R) Manifest Tool version 5.2.3790.2076 Copyright (c) Microsoft Corporation 2005. All rights reserved. Aspect.UCC.SmartClient.Shell.exe.manifest : manifest authoring warning 81010002: Unrecognized Element "application" in namespace "urn:schemas-microsof t-com:asm.v2". DeclareDPIAware.manifest : manifest authoring warning 81010002: Unrecognized Element "application" in namespace "urn:schemas-microsoft-com:asm.v3". :::::::::::::::::::::::::::::::::::::::::::::::::: The http://www.windows-api.com/microsoft/VC-MFC/31461243/vc2008-dpiaware-manifest.aspx says the warning is acceptable, and then I checked the Final.manifest which had nothing only the DeclareDPIAware.manifest contents... Any help would be appreciated........
2/6/2012
and for querying...
See: IsProcessDPIAware
7/10/2009
Recipe for XP SP2 Disaster
That <assembly> also has two schema properties. What does KB921337 have to say about that?

"The computer may restart ... in XP Service Pack 2"
http://support.microsoft.com/kb/921337

"This problem occurs when Csrss.exe is loading an .exe file or a .dll file that contains a manifest that has Windows Vista extensions. When parsing the embedded manifest, its internal memory can be corrupted if it finds a single tag that has two schema properties."
5/13/2009
Linker doesn't like that manifest snippet
Adding the sample manifest fragment as indicated causes the Linker to warn "manifest authoring warning 81010002: Unrecognized Element "application" in namespace "urn:schemas-microsoft-com:asm.v3"." Is this is a documentation bug?

At first I thought it was because I was using VS 2005, which didn't know about it. But I've upgraded to VS 2008, and I get the same warning. It's not just a warning, it actually leaves the fragment out of the manifest, so I still have to use the SetProcessDPIAware function.
10/25/2008