473,803 Members | 3,534 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 6042
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
8802
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
1818
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
1807
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
8522
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
1820
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
8846
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
5211
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
2750
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
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10317
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
10295
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
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6844
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();...
0
5501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.