473,324 Members | 2,501 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,324 software developers and data experts.

SystemParametersInfo

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

SystemParametersInfo(SPI_GETWORKAREA, 0, VarPtr(rc), 0)

but it returns the parameters in the "wrong" order, eg:

{System.Drawing.Rectangle}
Bottom: 1280
Empty: {System.Drawing.Rectangle}
Height: 0
IsEmpty: False
Left: 0
Location: {System.Drawing.Point}
Right: 994
Size: {System.Drawing.Size}
Top: 1280
Width: 994
X: 0
Y: 1280

where bottom should be 994 and right should be 1280. (I'm using the VarPtr
function that is around on the net, GCHandle etc).

If I redeclare SystemParametersInfo as:

Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer,
ByRef lpvParam As Rectangle, ByVal fuWinIni As Integer) As Integer

and say

SystemParametersInfo(SPI_GETWORKAREA, 0, rc, 0)

then the rc structure is populated correctly:

{System.Drawing.Rectangle}
Bottom: 994
Empty: {System.Drawing.Rectangle}
Height: 994
IsEmpty: False
Left: 0
Location: {System.Drawing.Point}
Right: 1280
Size: {System.Drawing.Size}
Top: 0
Width: 1280
X: 0
Y: 0

Two questions:

1) Why is there a difference between the two methods? I want to use the
first method if possible.
2) Is the second method a valid way of doing things, ie is it ok to have
multiple declarations?

Thanks.

David.
Nov 21 '05 #1
1 5102
Hi,

maybe the screen class can help you

for example: MsgBox(Screen.PrimaryScreen.WorkingArea().ToString )

hth Grtz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"David" <da*********@btinternet.com> schreef in bericht
news:d6**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
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

SystemParametersInfo(SPI_GETWORKAREA, 0, VarPtr(rc), 0)

but it returns the parameters in the "wrong" order, eg:

{System.Drawing.Rectangle}
Bottom: 1280
Empty: {System.Drawing.Rectangle}
Height: 0
IsEmpty: False
Left: 0
Location: {System.Drawing.Point}
Right: 994
Size: {System.Drawing.Size}
Top: 1280
Width: 994
X: 0
Y: 1280

where bottom should be 994 and right should be 1280. (I'm using the VarPtr
function that is around on the net, GCHandle etc).

If I redeclare SystemParametersInfo as:

Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As Rectangle, ByVal fuWinIni As Integer) As Integer

and say

SystemParametersInfo(SPI_GETWORKAREA, 0, rc, 0)

then the rc structure is populated correctly:

{System.Drawing.Rectangle}
Bottom: 994
Empty: {System.Drawing.Rectangle}
Height: 994
IsEmpty: False
Left: 0
Location: {System.Drawing.Point}
Right: 1280
Size: {System.Drawing.Size}
Top: 0
Width: 1280
X: 0
Y: 0

Two questions:

1) Why is there a difference between the two methods? I want to use the
first method if possible.
2) Is the second method a valid way of doing things, ie is it ok to have
multiple declarations?

Thanks.

David.

Nov 21 '05 #2

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...
2
by: philippe.joliet | last post by:
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 private...
0
by: kids_pro | last post by:
Hi there, What is the correct wayt o import this function from Win32 API? public static extern long SystemParametersInfo( ???? ) Regards
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: 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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.