Solved

SystemParametersInfo help

Posted on 2004-10-04
14
470 Views
Last Modified: 2013-12-04
Alright, this is rather confusing for me. I have a plugin I'm writing for a shell replacement program called Aston. It sets the work area for the desktop. Now on the PC I first wrote it on (XP), it works fine. I copied it over to my 2kServer machine and SystemParametersInfo returns error 87 (incorrect parameter). I made a new project and tried the same thing and it works. The only difference is in the plugin the RECT (LPRECT in this case) is in a structure I created. Now, I sent the plugin to a friend of mine who runs XP as well, and his machine gave the same error. I've tried various things as copying the RECT in the structure to a RECT in the function and this didn't help either. I've made sure all the RECT variables are valid by converting it to a string (wsprintf) and MessageBox'ing it.

If any more information is needed I can give it.
Thanks in advance.
0
Comment
Question by:Veratil
  • 7
  • 7
14 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 12221325
Is it possible packing is messed up?  Easy way to tell, if you copied the RECT by just copying the whole structure , try copying each of the four integers individually.  if it works, chances are it was the packing.

Althought I don't think it would cause this error, it is possible it could also be because you are trying to enlarge the work area to a size larger than the screen resolution.  If you are using absolute values that is a possibility.

If neither of these sound right, it might be worth posting the actual call and the code you use to calculate the rect.

Hope this helps.
0
 

Author Comment

by:Veratil
ID: 12221410
I copy each RECT variable individually. My testing variables aren't larger than the work area, but they could be set to it manually (which I'll have to fix that later, thanks for the tip there).

Each variable is set beforehand when the plugin is initialized (but I'm adding an option to change it while running, which works on my machine).

Here's the code:
RECT r;
r.left = cwad->setr->left; // setr is a LPRECT in the structure cwad
// so on for the others
if (!SystemParametersInfo(SPI_SETWORKAREA, 0, &r, SPIF_SENDCHANGE))
{
  error(...); // my error function
  return;
}
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 12221715
Um, I'm not sure if you are allowed to do a SPIF_SENDCHANGE with SPI_SETWORKAREA.  I think you need to follow it up with a PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0); instead, though I don't know why . . . it's just that every example I've seen does that.

Other than that, the code looks fine.  Are any of the systems you are working on Multi-monitor?
0
 

Author Comment

by:Veratil
ID: 12221787
Well, I tried that, and it still errors. :(

None of my computers are multimonitor, but if you could give me a few examples or some explaination I'd greatly appreciate it.

Do you have any other ideas of why this could be happening?
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 12221933
Do a google search for SPI_SETWORKAREA and you will get 10 pages of examples.  This one is probably the most representative, though: http://www.codeguru.com/Cpp/W-P/system/taskbar/article.php/c5747/
0
 

Author Comment

by:Veratil
ID: 12222499
I've tried everything from everything I can find. Nothing works. :(
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 12226619
I assume you installed the screen management program on the other computers.  Does it create virtual monitors (like KDE and Gnome do)?  It's just that the only restriction I can find is that the rectangle must be expressed in virtual screen coordinates, so if it accidentally went even a pixel onto a different virtual screen, it is possible the function would fail on the grounds that the rectangle must be on a single monitor.

The code in the example I gave works fine on my machine.

Just as a test, add

SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);

just before

if (!SystemParametersInfo(SPI_SETWORKAREA, 0, &r, SPIF_SENDCHANGE))

and see if it still fails.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Veratil
ID: 12227174
I transfered the code over to the 2k machine and tried various things, and that was one of them. That ended up working. BUT... I came back to the code on my machine (XP), updated it, tried it, and it failed again. Same code, but just compiled on XP instead of 2k. Is there anything that could cause things like that?
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 12227450
Hmm, is it possible that the compiler has different settings under XP than the one running on Win2000?  I can't think of what would be causing this, though.  What compiler are you using?  Is it possible that one is patched and the other is not?

This sounds very suspiciously like something is wrong that has nothing to do with your program.
0
 

Author Comment

by:Veratil
ID: 12227479
I copied the entire project. I'm using Visual C++ 6 and each is the same, updated with the platform sdk and everything.

It might be something wrong with the settings, but I don't see how as it's the same project.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 12227722
There are compiler settings too, but none that I know of that cause certain machines to not work.  I assume the 3rd part lib files are the same on both machines (if there are any).  Hmm, very odd.

Just to get a sanity check, make sure that MFC42.dll, MSVCRT.DLL and the D versions of those are the same on both computers.  Microsoft (rather stupidly I think) decided to keep the same DLL file names when they updated MFC and it caused all sorts of unpleasant little difficulties.  If they are different, maybe switching to statically linked MFC would solve the problem.
0
 

Author Comment

by:Veratil
ID: 12227830
I don't use MFC, and I don't use the msvcrt library as that makes the plugin not even be recognized on 2k machines. I don't know why this is or if it's just another setting somewhere in VC++.
0
 
LVL 11

Accepted Solution

by:
KurtVon earned 120 total points
ID: 12228348
That is very odd indeed.

Obviously the plugin behavior is different on different machines, but since SystemParametersInfo is a Kernel function, I'm not sure how that would be caused by a compiler setting or a library.  At this point I cannot offer any advice beyond "don't develop on the XP machine."
0
 

Author Comment

by:Veratil
ID: 12234306
Yeah, but I really want to figure out why this is happening. I guess if anyone else has any ideas then feel free to help out. If not in a day or two I'll give the answer to you, KurtVon.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now