Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6023253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:58:38+00:00 2026-05-23T03:58:38+00:00

I have been trying for quite a while now to resize the desktop work

  • 0

I have been trying for quite a while now to resize the desktop work area (the area where windows get maximized). I have found the required API, but I can’t seem to resize the work area. It does just nothing.

I use Windows 7 Ultimate x64 so I also tried compiling it in x64 ‘mode’, and still no luck. Could someone give me a push in the right direction?

Here is what I got so far:

[DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]
private static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, IntPtr lpvParam, Int32 fuWinIni);

private const Int32 SPIF_SENDWININICHANGE = 2;
private const Int32 SPIF_UPDATEINIFILE = 1;
private const Int32 SPIF_change = SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE;
private const Int32 SPI_SETWORKAREA = 47;
private const Int32 SPI_GETWORKAREA = 48;

public struct RECT
{
    public Int32 Left;
    public Int32 Right;
    public Int32 Top;
    public Int32 Bottom;
}

private static int SetWorkspace(RECT oRECT)
{
    IntPtr ptr = IntPtr.Zero;
    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(oRECT));
    Marshal.StructureToPtr(oRECT, ptr, true);
    return SystemParametersInfo(SPI_SETWORKAREA, Marshal.SizeOf(oRECT), ptr, SPIF_change);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:58:38+00:00Added an answer on May 23, 2026 at 3:58 am

    The following code should work just fine:

    // 1. Change the function to call the Unicode variant, where applicable.
    // 2. Ask the marshaller to alert you to any errors that occur.
    // 3. Change the parameter types to make marshaling easier. 
    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool SystemParametersInfo(
                                                    int uiAction,
                                                    int uiParam,
                                                    ref RECT pvParam,
                                                    int fWinIni);
    
    private const Int32 SPIF_SENDWININICHANGE = 2;
    private const Int32 SPIF_UPDATEINIFILE = 1;
    private const Int32 SPIF_change = SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE;
    private const Int32 SPI_SETWORKAREA = 47;
    private const Int32 SPI_GETWORKAREA = 48;
    
    [StructLayout(LayoutKind.Sequential)]
    public struct RECT
    {
        public Int32 Left;
        public Int32 Top;   // top is before right in the native struct
        public Int32 Right;
        public Int32 Bottom;
    }
    
    private static bool SetWorkspace(RECT rect)
    {
       // Since you've declared the P/Invoke function correctly, you don't need to
       // do the marshaling yourself manually. The .NET FW will take care of it.
    
       bool result = SystemParametersInfo(SPI_SETWORKAREA,
                                          IntPtr.Zero,
                                          ref RECT,
                                          SPIF_change);
       if (!result)
       {
           // Find out the error code
           MessageBox.Show("The last error was: " +
                           Marshal.GetLastWin32Error().ToString());
       }
    
       return result;
    }
    

    But I’m not really sure what you’re trying to do. By default, the work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. You’re not going to be able to make it any larger than the area that’s available on your screen (neat trick if you could, though!). Do your windows not already fill the entire screen when you maximize them?

    And even on machines with multiple monitors, you can’t set the working area to span multiple monitors. The MSDN documentation says that it’s constrained to setting the working area of the monitor that contains the specified rectangle:

    In a system with multiple display monitors, the function sets the work area of the monitor that contains the specified rectangle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to get this working for quite a while now but
I have been trying to get around this error for a day now and
Been trying this for quite a while now and I need help. Basically I
I've been trying this for quite a while now, but can't figure it out.
I have been trying to work my way through Project Euler, and have noticed
I have been trying to make a case for using Python at my work.
I been using the jquery ui for quite a while now. This is the
I have been trying for a month and a half now to transfer files
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.