Hi,
I am trying to DllImport ChangeDisplaySettingsEx function from user32.dll.
It works well, unless I try to use it in order to get VIDEOPARAMETERS
struct.
When I pass the struct the function returns DISP_CHANGE_BADPARAM and the
struct doesn't get filled.
This is the DllImport:
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettingsEx(string deviceName,ref
DEVMODE1 devMode,IntPtr hwnd, int flags, ref VIDEOPARAMETERS vidParam);
I wrapped the VIDEOPARAMETERS struct and Initialized it with:
VIDEOPARAMETERS vp = new VIDEOPARAMETERS();
vp.bOEMCopyProtection = new char[256];
vp.guid = new Guid("{02C62061-1097-11d1-920F-00A024DF156E}");
vp.dwCommand = VP_COMMAND_GET;
Hope someone can help me.
Tomer.
P.S - here's a link to the documentation on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_3tfc.asp
Mattias Sj?gren - 16 Sep 2004 23:35 GMT
>Hope someone can help me.
Not without seeing your VIDEOPARAMETERS declaration, I suspect it's
incorrect.
You may find a working one at www.pinvoke.net
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
tomer - 17 Sep 2004 09:01 GMT
Hi,
pinvoke.net has only the DllImport without the VIDEOPARAMETERS struct. (my
dllimport works just fine without the VP struct).
That's my decleration:
[StructLayout(LayoutKind.Sequential)]
public struct VIDEOPARAMETERS
{
public System.Guid guid;
public ulong dwOffset;
public ulong dwCommand;
public ulong dwFlags;
public ulong dwMode;
public ulong dwTVStandard;
public ulong dwAvailableModes;
public ulong dwAvailableTVStandard;
public ulong dwFlickerFilter;
public ulong dwOverScanX;
public ulong dwOverScanY;
public ulong dwMaxUnscaledX;
public ulong dwMaxUnscaledY;
public ulong dwPositionX;
public ulong dwPositionY;
public ulong dwBrightness;
public ulong dwContrast;
public ulong dwCPType;
public ulong dwCPCommand;
public ulong dwCPStandard;
public ulong dwCPKey;
public ulong bCP_APSTriggerBits;
public char[] bOEMCopyProtection;
};
Good chance I'm doing something wrong ... I'm pretty new to Interoping.
Thanks,
Tomer.
>>Hope someone can help me.
>
[quoted text clipped - 4 lines]
>
> Mattias
Mattias Sj?gren - 17 Sep 2004 08:27 GMT
All ulong members should be changed to uint.
The bOEMCopyProtection member should have the attribute
[MarshalAs(UnmanagedType.ByValArray, SizeConst=256)]
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
tomer - 17 Sep 2004 11:10 GMT
All working!
Thanks alot!!!!
Have a wonderful day!
Tomer.
> All ulong members should be changed to uint.
>
> The bOEMCopyProtection member should have the attribute
> [MarshalAs(UnmanagedType.ByValArray, SizeConst=256)]
>
> Mattias