473,834 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SystemParameter sInfo problems

Hello,

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

I've got this definition

[DllImport("user 32.dll")]
private static extern int SystemParameter sInfo(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 6045
Philippe,

The SystemParameter sInfo 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************* *@exisconsultin g.com

<ph************ *@valain.com> wrote in message
news:99******** *************** ***@posting.goo gle.com...
Hello,

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

I've got this definition

[DllImport("user 32.dll")]
private static extern int SystemParameter sInfo(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(Rec tangle scrLimit)
{
GUIRECT rect;
IntPtr p;

rect.left=scrLi mit.Left;
rect.top=scrLim it.Top;
rect.right=scrL imit.Right;
rect.bottom=scr Limit.Bottom;

p = Marshal.AllocHG lobal(Marshal.S izeOf(rect));

Marshal.Structu reToPtr(rect,p, false);
int i=SystemParamet ersInfo(SPI_SET WORKAREA,0,p,0) ;

int ret=Marshal.Get LastWin32Error( );

}
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************ **@exisconsulti ng.com> wrote in message news:<Oa******* *******@TK2MSFT NGP12.phx.gbl>. ..
Philippe,

The SystemParameter sInfo 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************* *@exisconsultin g.com

<ph************ *@valain.com> wrote in message
news:99******** *************** ***@posting.goo gle.com...
Hello,

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

I've got this definition

[DllImport("user 32.dll")]
private static extern int SystemParameter sInfo(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
485
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 it back to -0-). Theoretically this should be easy to accomplish through the call shown below. If I trace the call with SysInternals (si)Registry Monitor I can see the call being made. Unfortunately in the si QueryValue for the key...
5
8803
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) - DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL But this doesn't: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
2
1819
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 following. public static extern int SystemParametersInfo(int uiAction, int uiParam, string pvParam, int fuWinIni);
1
1808
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
8523
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 for API functions? Is there any help for this available anywhere?
1
1821
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 always equals to Zero.But the same code in VC++ 6.0 works well! Why ?? What things I should do for query the right value in
3
8851
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 appreciated! TIA, Shamil --
1
5212
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, ByVal uParam As Integer, ByRef lpvParam As Integer, ByVal fuWinIni As Integer) As Integer Dim rc As Rectangle
1
2753
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 SPI_SETDEFAULTINPUTLANG and you have to use the HKL. But I really do not understand how to do that. I would be very grateful for help! BigWilli
0
9643
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10789
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10504
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10544
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9327
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7755
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.