There are several problems with your PInvoke definition.
1) The function return value should be int not long. 32-bit is int and long
is 64 bit and is not supported for PInvoke
2) DEVMODE structure should be passed as ref not out
3) DEVMODE structure contains two embedded strings and as such cannot be
marshalled. You need to use byte array instead
Use technique described here:
http://msdn.microsoft.com/library/en...essManager.asp
"Franky" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I try to change for landscape orientation.
> i use the ChangeDisplaySettingsEx function.
> ----
> [DllImport("coredll.dll", EntryPoint="ChangeDisplaySettingsEx",
> SetLastError=true)]
> internal static extern long ChangeDisplaySettingsEx(
> string lpszDeviceName,
> out DEVMODE lpDevMode,
> IntPtr hwnd,
> int dwflags,
> IntPtr lParam);
> ---
> my struct DEVMODE is
> ---
> [StructLayout(LayoutKind.Sequential)]
> public struct DEVMODE
> {
> string dmDeviceName;
> public int dmSpecVersion;
> public int dmDriverVersion;
> public int dmSize;
> public int dmDriverExtra;
> public long dmFields;
> public short dmOrientation;
> public short dmPaperSize;
> public short dmPaperLength;
> public short dmPaperWidth;
> public short dmScale;
> public short dmCopies;
> public short dmDefaultSource;
> public short dmPrintQuality;
> public short dmColor;
> public short dmDuplex;
> public short dmYResolution;
> public short dmTTOption;
> public short dmCollate;
> public string dmFormName;
> public int dmLogPixels;
> public int dmBitsPerPel;
> public int dmPelsWidth;
> public int dmPelsHeight;
> public int dmDisplayFlags;
> public int dmDisplayFrequency;
> public int dmDisplayOrientation;
> }
> ---
>
>
> I try different way... a got always a Unmanaged Exception!
>
> Can someone HELP ME PLEASE!!!!!
>
>
>