调用EnumDisplaySettings为什么会报错? (100分)

  • 主题发起人 主题发起人 Kim Wong
  • 开始时间 开始时间
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>&nbsp; retCode: BOOL;<br>&nbsp; DisplayDevice: TDisplayDevice;<br>&nbsp; DevMode: TDevMode;<br>&nbsp; ModeNum: DWORD;<br>&nbsp; Str1: string;<br>begin<br>&nbsp; DisplayDevice.cb := SizeOf(TDisplayDeviceW);<br>&nbsp; RetCode := EnumDisplayDevices(nil, 0, DisplayDevice, 0);<br>&nbsp; if retCode = False then<br>&nbsp; &nbsp; Exit;<br><br>&nbsp; ModeNum := 0;<br>&nbsp; repeat<br>&nbsp; &nbsp; RetCode := EnumDisplaySettings(DisplayDevice.DeviceName,<br>&nbsp; &nbsp; &nbsp; &nbsp; ModeNum, DevMode);<br>&nbsp; &nbsp; if RetCode &lt;&gt; False then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; [red]Str1 := Format('%d x %d, %d',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [DevMode.dmPelsWidth,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DevMode.dmPelsHeight,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DevMode.dmBitsPerPel]);[/red]<br>&nbsp; &nbsp; &nbsp; ComboBox1.Items.Add(Str1);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; ModeNum := ModeNum + 1;<br>&nbsp; until RetCode = False;<br>end;
 
沉得太快了,再顶一把 [:)]
 
后退
顶部