Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2004

Tip: Looking for answers? Try searching our database.

ChangeDisplaySettingsEx

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tomer - 16 Sep 2004 14:01 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.