473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SystemParametersInfo problems

Hello,

I'm currently try to use the SystemParametersInfo function in a c#
environnement but I have a problem to use it with the action
SPI_SETWORKAREA

I've got this definition

[DllImport("user32.dll")]
private static extern int SystemParametersInfo(int uAction, int
uParam, string pvParam, int fuWinIni);

in the SDK it is shown that I must pass to pvParam a pointer to a RECT
structure and not a string.

How do I do that?

I tried to define a struct equivalent to the RECT structure but it
does not seems to work :(

If you 've got an idee? it will be helpfull

In advance, thanks
Nov 15 '05 #1
2 6020
Philippe,

The SystemParametersInfo API call takes a pointer where the data
returned is to be written to. Because of this, you should declare the
parameter as an IntPtr and then marshal the information yourself based on
what the return value is.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

<ph*************@valain.com> wrote in message
news:99**************************@posting.google.c om...
Hello,

I'm currently try to use the SystemParametersInfo function in a c#
environnement but I have a problem to use it with the action
SPI_SETWORKAREA

I've got this definition

[DllImport("user32.dll")]
private static extern int SystemParametersInfo(int uAction, int
uParam, string pvParam, int fuWinIni);

in the SDK it is shown that I must pass to pvParam a pointer to a RECT
structure and not a string.

How do I do that?

I tried to define a struct equivalent to the RECT structure but it
does not seems to work :(

If you 've got an idee? it will be helpfull

In advance, thanks

Nov 15 '05 #2
Thanks Nicholas,

I've explored this way and I've written this method:

public void SetWorkArea(Rectangle scrLimit)
{
GUIRECT rect;
IntPtr p;

rect.left=scrLimit.Left;
rect.top=scrLimit.Top;
rect.right=scrLimit.Right;
rect.bottom=scrLimit.Bottom;

p = Marshal.AllocHGlobal(Marshal.SizeOf(rect));

Marshal.StructureToPtr(rect,p,false);
int i=SystemParametersInfo(SPI_SETWORKAREA,0,p,0);

int ret=Marshal.GetLastWin32Error();

}
private struct GUIRECT
{
public long left;
public long top;
public long right;
public long bottom;

}
and the ret integer as a value of 87 (incorrect parameter)

Something I was wondering is the SPI_SETWORKAREA command is a "write"
command and the third parameter is only read or I miss something?

I'm not very familiar with Marshaling, and I hope once more that you
can help me. I known that I'm perhaps abusing but I'm wasting time on
this little detail of my application, I'm getting nervous

Thanks a lot

Philippe


"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:<Oa**************@TK2MSFTNGP12.phx.gbl>...
Philippe,

The SystemParametersInfo API call takes a pointer where the data
returned is to be written to. Because of this, you should declare the
parameter as an IntPtr and then marshal the information yourself based on
what the return value is.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

<ph*************@valain.com> wrote in message
news:99**************************@posting.google.c om...
Hello,

I'm currently try to use the SystemParametersInfo function in a c#
environnement but I have a problem to use it with the action
SPI_SETWORKAREA

I've got this definition

[DllImport("user32.dll")]
private static extern int SystemParametersInfo(int uAction, int
uParam, string pvParam, int fuWinIni);

in the SDK it is shown that I must pass to pvParam a pointer to a RECT
structure and not a string.

How do I do that?

I tried to define a struct equivalent to the RECT structure but it
does not seems to work :(

If you 've got an idee? it will be helpfull

In advance, thanks

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mike S. | last post by:
I'm using a SystemParametersInfo call to attempt to manage the screen saver. All I want to do is modify the ScreenSaveActive bit in the registry and have the OS recognize it (and occasionally set...
5
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
2
by: Dwight Trumbower | last post by:
I need to disable the screen saver, due to an Excel "bug". I thought I had the following code working, but now all I get is code 127. I've searched the net and I don't see anything wrong with the...
1
by: Mohammad-Reza | last post by:
In SystemParametersInfo API, type of its pvParam is PVOID. I want to know what type I must use to both set and get of this api works properly.
2
by: GTi | last post by:
I need the csharp (C#) function for this API function: SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); Or must I pInvoke this (also)? My biggest problem with C# is to find the C# function...
1
by: kenwhale | last post by:
hi, all. In my computer(windows2000 professional), I found this code doesn't work! SystemParametersInfo(0x2000/*SPI_GETFOREGROUNDLOCKTIMEOUT*/,0,&dwTimeOut,0)) ; The value of dwTimeOut...
3
by: Shamil Salakhetdinov | last post by:
Hi All, I did try by myself and I did search on google but I can't find any info on how to use SystemParametersInfo Win32API in VB.NET Any useful samples, hints, tips & tricks will be greatly...
1
by: David | last post by:
Hi, I'm trying to use SystemParametersInfo to get the desktop work area: Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer,...
1
by: BigWilli | last post by:
Hello, I want to change the keyboard language. Does anyone have an example code in VB6 for that? I know already from MSDN that it should be possible with the SystemParametersInfo and the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.