未知的SetProcessDpiAwareness错误结果

时间:2018-06-05 03:41:15

标签: vb.net winapi hdpi

我有50台中的一台计算机从SetProcessDpiAwareness返回非零结果,我找不到任何关于它的信息。我正在设置DPI意识到不知道。我有一台计算机返回值105621835743232(十进制)。它似乎仍然将DPI意识设置为不应该意识到它应该但是会给出一个不期望的返回值。

Private Declare Function SetProcessDpiAwareness Lib "shcore.dll" (ByVal Value As PROCESS_DPI_AWARENESS) As Long

Private Function SetDPI() As Long
    'Results from SetProcessDPIAwareness
    'Const S_OK = &H0&
    'Const E_INVALIDARG = &H80070057
    'Const E_ACCESSDENIED = &H80070005
    Dim lngResult As Long
    lngResult = SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_DPI_Unaware)
    Return lngResult

End Function

这是一个clickonce winforms应用程序,因此我无法使用清单来设置DPI。

非常欢迎任何有关查找文档的帮助!

提前致谢。

1 个答案:

答案 0 :(得分:5)

This API function's return value is a 32 bit integer so you should use Integer rather than Long. Note that Long is a 64 bit type.

I also strongly recommend using p/invoke rather than Declare. The latter exists for compatibility reasons. P/invoke offers much greater control of the import process.