K
Kim Wong
Unregistered / Unconfirmed
GUEST, unregistred user!
每次运行到 Str1 := Format('%d x %d, %d', [DevMode.dmPelsWidth, DevMode.dmPelsHeight, DevMode.dmBitsPerPel]) 的时候都会报错"存取违例"<br>代码如下,不知道是什么地方出错了,请高手指点:<br>
代码:
procedure TFormTest.Button1Click(Sender: TObject);<br>var<br> retCode: BOOL;<br> DisplayDevice: TDisplayDevice;<br> DevMode: TDevMode;<br> ModeNum: DWORD;<br> Str1: string;<br>begin<br> DisplayDevice.cb := SizeOf(TDisplayDeviceW);<br> RetCode := EnumDisplayDevices(nil, 0, DisplayDevice, 0);<br> if retCode = False then<br> Exit;<br><br> ModeNum := 0;<br> repeat<br> RetCode := EnumDisplaySettings(DisplayDevice.DeviceName,<br> ModeNum, DevMode);<br> if RetCode <> False then<br> begin<br> [red]Str1 := Format('%d x %d, %d',<br> [DevMode.dmPelsWidth,<br> DevMode.dmPelsHeight,<br> DevMode.dmBitsPerPel]);[/red]<br> ComboBox1.Items.Add(Str1);<br> end;<br> ModeNum := ModeNum + 1;<br> until RetCode = False;<br>end;