Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

SystemParametersInfo help

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
Veratil
Asked:
Veratil
  • 7
  • 7
1 Solution
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
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
 
KurtVonCommented:
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
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
VeratilAuthor Commented:
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
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
I've tried everything from everything I can find. Nothing works. :(
0
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
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
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
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
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
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
 
KurtVonCommented:
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
 
VeratilAuthor Commented:
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now