'デバイスコンテキストを得る <DllImport("coredll.dll")> _ Private Shared Function GetDC(ByVal hwnd As IntPtr) As IntPtr End Function 'デバイスコンテキストを解放する <DllImport("coredll.dll")> _ Private Shared Function ReleaseDC(ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As Boolean End Function '指定されたデバイスに関するデバイス固有情報を取得します。 <DllImport("coredll.dll")> _ Private Shared Function GetDeviceCaps _ (ByVal hdc As IntPtr, ByVal nIndex As Integer) As Integer End Function Private Const HORZRES As Integer = 8 '画面の幅 (ピクセル単位) Private Const VERTRES As Integer = 10 '画面の高さ (ピクセル単位) Private Const LOGPIXELSX As Integer = 88 '論理インチ当たりの画面の水平方向のピクセル数 Private Const LOGPIXELSY As Integer = 90 '論理インチ当たりの画面の垂直方向のピクセル数 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button2.Click Dim ScreenHdc As IntPtr = GetDC(Me.Handle) 'SCREEN SIZE Dim screenX As Integer = GetDeviceCaps(ScreenHdc, HORZRES) Dim screenY As Integer = GetDeviceCaps(ScreenHdc, VERTRES) 'DPI Dim dpiX As Integer = GetDeviceCaps(ScreenHdc, LOGPIXELSX) Dim dpiY As Integer = GetDeviceCaps(ScreenHdc, LOGPIXELSY) ReleaseDC(Me.Handle, ScreenHdc) MessageBox.Show(String.Format("screenX:{0}、screenY:{1}、dpiX:{2}、dpiY:{3}",screenX,screenY, dpiX, dpiY)) End Sub
WS007SH、X04HTでは以下の値が返りました。
screenX:480
screenY:640
dpiX:192
dpiY:192
CASIO DT-5200
QVGA
screenX:480
screenY:640
dpiX:96
dpiY:96
VGA
screenX:240
screenY:320
dpiX:96
dpiY:96
0 件のコメント:
コメントを投稿