That's exactly what I wanted to say. Then again, after reading nil^ I was first too busy laughing about such a very obvious error. ;-)
But to be more serious... The problem is that in the Windows unit, this function is declared as: function ChangeDisplaySettings(var lpDevMode: TDeviceMode; dwFlags: DWORD): Longint; stdcall; Now checking the http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_7gz7.asp page, I immediately see the problem. You have to send a nil to this function but unfortunately, Delphi doesn't allow this to be used with VAR parameters. So how to get around this? Well, this code should work: ChangeDisplaySettings(PDeviceMode(Nil)^, 0); However, it might be easier to just re-include this function in your source like this: function ChangeDisplaySettings(lpDevMode: pDeviceMode; dwFlags: DWORD): Longint; stdcall; external 'user32.dll' name 'ChangeDisplaySettingsA'; And then you can just use: ChangeDisplaySettings(Nil, 0); Simply because this function is now better defined than the Delphi version. But it means adjusting code at more than one location. I would use: ChangeDisplaySettings(Nil,0); or ChangeDisplaySettings(TDeviceMode(Nil),0); though... That is This is a well-known problem with some of the Delphi WINAPI convertions. Delphi has defined them as VAR parameters yet the WINAPI allows nil values tto be used here. Personally, I would have preferred it if Borland just kept these things as pointers instead as VAR parameters but then again, no one else seems to be complaining about this and it's probably been in there for about 7 Delphi versions... With kind regards, X Katja Bergman. (Who still has to giggle about it.) --- In [email protected], "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi Shweta, > my windows help says to call ChangeDisplaySettings(0,0) or ChangeDisplaySettings(Null,0) > your construction of TDeviceMode(Nil^) is invalid an should lead to access violations because Nil is never adressing anything. > > Have fun > Bob > > > > I am calling method as ChangeDisplaySettings(TDeviceMode(Nil^),0). > > According to documentation of ChangeDisplaySettings, it should restore the > > default display settings that are stored in registry, but it is not doing > > so. Can any body suggest the reason. > > > > > > ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

