Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windowing
Windows
Windows Reference
Functions
 SetProcessDPIAware Function
SetProcessDPIAware Function

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

Syntax

BOOL SetProcessDPIAware(VOID);

Return Value

On success, the return value is nonzero. Otherwise, the return value is zero.

Remarks

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.

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].

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows Vista
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Linker doesn't like that manifest snippet      aidtopia ... Thomas Lee   |   Edit   |  
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.
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker