ab.com コミュニティ https://www.activebasic.com/forum/ |
|
共用体 https://www.activebasic.com/forum/viewtopic.php?t=580 |
ページ 1 / 1 |
作成者: | NoWest [ 2005年12月23日(金) 00:01 ] |
記事の件名: | 共用体 |
兎に角、こいつが一番欲しいですね。 使用するときには次のような形式のものが良いと思います。 コード: 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で定義されている構造体には結構共用体があります。 妄想で共用体を使用した例 [ここをクリックすると内容が表示されます]
WEBのサンプルを見ながら、ActiveBasicで動かそうとした時、
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 「構造体にある筈のメンバが無い」ってことが良くあるんですね。 (特にVBから移植した構造体を使ってVCのサンプルを動かすとき) ちょっとデータ構造に詳しい人なら簡単に解決できることですが 初めての人はびっくりしますよね。これ、 |
ページ 1 / 1 | 全ての表示時間は UTC+09:00 です |
Powered by phpBB® Forum Software © phpBB Limited https://www.phpbb.com/ |