兎に角、こいつが一番欲しいですね。
使用するときには次のような形式のものが良いと思います。
コード:
Type SYSTEM_INFO
Union
dwOemId As DWord
Type
wProcessorArchitecture As Word
wReserved As Word
End Type
End Union
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type
共用体が使われている構造体は以外に多いですし、
移植時のサイズ合わせや実行時のデータ取出しが結構大変です。
と言うことで共用体とセットで下のも必要です。
コード:
Type
wProcessorArchitecture As Word
wReserved As Word
End Type
共用体を採用するとどうしても名前なしの構造体が必要ですよね。
この場合、構造体と言うよりは調整体と呼ぶほうが正しいですが、
SYSTEM_INFO構造体以外にもABで定義されている構造体には結構共用体があります。
妄想で共用体を使用した例 [ここをクリックすると内容が表示されます] [ここをクリックすると非表示にします]
ULARGE_INTEGER構造体も
コード:
Union ULARGE_INTEGER
Type
LowPart As DWord
HighPart As DWord
End Type
QuadPart As QWord
End Union
のように定義しておけば便利ですし、
印刷やディスプレイの設定に使うDEVMODE構造体は
コード:
Type DEVMODE
dmDeviceName(31) As Byte
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
Union
Type
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
End Type
dmPosition As POINTAPI
End Union
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName(31) As Byte
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
Union
dmDisplayFlags As Long
dmNup As Long
End Union
dmDisplayFrequency As Long
End Type
WEBのサンプルを見ながら、ActiveBasicで動かそうとした時、
「構造体にある筈のメンバが無い」ってことが良くあるんですね。
(特にVBから移植した構造体を使ってVCのサンプルを動かすとき)
ちょっとデータ構造に詳しい人なら簡単に解決できることですが
初めての人はびっくりしますよね。これ、