タイトル | : Re: 構造体を引数とするAPI(SystemParametersInfo) |
記事No | : 9526 |
投稿日 | : 2009/10/29(Thu) 10:09 |
投稿者 | : オショウ |
Private Const SPI_GETICONMETRICS As Integer = 45 Private Const LF_FACESIZE As Int32 = 32
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=1)> _ Private Structure LOGFONT Public lfHeight As Int32 Public lfWidth As Int32 Public lfEscapement As Int32 Public lfOrientation As Int32 Public lfWeight As Int32 Public lfItalic As Byte Public lfUnderline As Byte Public lfStrikeOut As Byte Public lfCharSet As Byte Public lfOutPrecision As Byte Public lfClipPrecision As Byte Public lfQuality As Byte Public lfPitchAndFamily As Byte <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=LF_FACESIZE)> Public lfFaceName As String End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)> _ Private Structure ICONMETRICS Public cbSize As Int32 '構造体のバイト数 Public iHorzSpacing As Int32 '水平方向の間隔 Public iVertSpacing As Int32 '同、垂直方向 Public iTitleWrap As Int32 '0のとき、キャプションを折り返さない Public lfFont As LOGFONT 'キャプションのフォントを指定するLOGFONT構造体 Public Sub New(ByVal dummy As Integer) lfFont = New LOGFONT End Sub End Structure
<DllImport("USER32.DLL", CharSet:=CharSet.Auto, EntryPoint:="SystemParametersInfo", SetLastError:=True)> _ Private Shared Function SystemParametersInfo( _ ByVal uAction As Integer, _ ByVal uparam As Integer, _ <[In](), Out()> ByRef lpvParam As ICONMETRICS, _ ByVal fuWinIni As Integer _ ) As Boolean End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim im As ICONMETRICS Dim bRet As Boolean
im = New ICONMETRICS(0) im.cbSize = Marshal.SizeOf(im)
bRet = SystemParametersInfo(SPI_GETICONMETRICS, Marshal.SizeOf(im), im, 0)
End Sub
こんなんで如何?
※ VISTA Ultimate で動作しました。
以上。参考まで
|