C # Use the ShowWindowAsync api function to control the form,
1. The System. Runtime. InteropServices name must be specified.
2. Declare the ShowWindowAsync Function
[DllImport ("user32.dll")]
Private static extern bool ShowWindowAsync (
IntPtr hWnd,
Int nCmdShow
);
3. Declare the ShowWindow Function
[DllImport ("user32.dll")]
Public static extern int ShowWindow (
Int hwnd,
Int nCmdShow
);
4. Declare API constant definition
// API constant definition
Private const int SW_HIDE = 0;
Private const int SW_NORMAL = 1;
Private const int SW_MAXIMIZE = 3;
Private const int SW_SHOWNOACTIVATE = 4;
Private const int SW_SHOW = 5;
Private const int SW_MINIMIZE = 6;
Private const int SW_RESTORE = 9;
Private const int SW_SHOWDEFAULT = 10;
5. The functions of the above functions are the same. They are used to set the window size. The difference is that the declared types are different and need to be optimized.
ShowWindowAsync (this. Handle, SW_MINIMIZE );
ShowWindow (int) this. Handle, SW_MINIMIZE );
6.IntIf you change to IntPtr, you do not need to use the preview type when using ShowWindow. Therefore, you can use the Preview data type at the time of announcement, which is free of manual data.
[DllImport ("user32.dll")]
Public static extern int ShowWindow (
IntHwnd,
Int nCmdShow
);
C # complete Samples
Using System;
Using System. Windows. Forms;
Using System. Runtime. InteropServices;
Namespace CS_WindowsResize
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
// API constant definition
Private const int SW_HIDE = 0;
Private const int SW_NORMAL = 1;
Private const int SW_MAXIMIZE = 3;
Private const int SW_SHOWNOACTIVATE = 4;
Private const int SW_SHOW = 5;
Private const int SW_MINIMIZE = 6;
Private const int SW_RESTORE = 9;
Private const int SW_SHOWDEFAULT = 10;
[DllImport ("user32.dll")]
Private static extern bool ShowWindowAsync (
IntPtr hWnd,
Int nCmdShow
);
[DllImport ("user32.dll")]
Public static extern int ShowWindow (
Int hwnd,
Int nCmdShow
);
Private void button#click (object sender, EventArgs e)
{
// Minimize
ShowWindowAsync (this. Handle, SW_MINIMIZE );
}
Private void button2_Click (object sender, EventArgs e)
{
// Maximize
ShowWindowAsync (this. Handle, SW_MAXIMIZE );
}
Private void button3_Click (object sender, EventArgs e)
{
// Restore original
ShowWindowAsync (this. Handle, SW_RESTORE );
}
Private void button4_Click (object sender, EventArgs e)
{
// Minimize
ShowWindow (int) this. Handle, SW_MINIMIZE );
}
Private void button5_Click (object sender, EventArgs e)
{
// Maximize
ShowWindow (int) this. Handle, SW_MAXIMIZE );
}
Private void button6_Click (object sender, EventArgs e)
{
// Restore original
ShowWindow (int) this. Handle, SW_RESTORE );
}
}
}
Reprinted from: http://www.dotblogs.com.tw/yc421206/archive/2009/07/06/9140.aspx
C :\
Yes
Refer to this to clean up the C drive:
1. Disable System Restoration: My computer properties/System Restoration/disable System Restoration on all disks, but I will not be able to use system restoration in the future!
2. Disable System sleep: Control Panel/Power Supply/sleep/remove the check before starting system sleep
3. move the virtual memory, my computer properties/advanced/performance/settings/advanced/change/select the C disk, that is, the system disk, select the no-score page, and then set the virtual memory to its disk, A disk with more disk space remaining, such as D, E, and F. set to 1.5 ~ of memory ~ 2.5 times. The size can be set to the same!
5. Clear temporary IE folders, internet Options, and delete temporary and offline files.
6. delete system logs and program logs, my computer/control panel/management tools/Computer Management/Event Viewer/application, right-click/clear events, and clear system logs in sequence
7. Clear system cache: 2000 all files in the system: C: \ WINNT \ system32 \ dllcache
The XP system is: C: \ windows \ system32 \ dllcache all files under the system cache (open my computer/tool/file and Folder Options/hide the protected system file hook off to hide all files on the hook) ). You can also run the sfc.exe/purgecache command to automatically delete the file.
8. Clear the recycle bin
9. delete the files under c: \ windows \ SoftwareDistribution \ Download (the files downloaded when the system is updated are useless if you have installed the updates)
10. Delete all directories under c: \ windows \ RegisteredPackages
11. Delete all Files under C: \ WINDOWS \ Downloaded Program Files
12. view the hidden files that are known to be protected by the system in my computer folder option, and check all the files.
13. Delete c: \ windows \ All files with $8882305 $ (backup files after system update)
Zhidao.baidu.com/question/11035955.html
Zhidao.baidu.com/question/12223613.html
Zhidao.baidu.com/question/14874715.html
... The remaining full text>
C :\
Yes
Refer to this to clean up the C drive:
1. Disable System Restoration: My computer properties/System Restoration/disable System Restoration on all disks, but I will not be able to use system restoration in the future!
2. Disable System sleep: Control Panel/Power Supply/sleep/remove the check before starting system sleep
3. move the virtual memory, my computer properties/advanced/performance/settings/advanced/change/select the C disk, that is, the system disk, select the no-score page, and then set the virtual memory to its disk, A disk with more disk space remaining, such as D, E, and F. set to 1.5 ~ of memory ~ 2.5 times. The size can be set to the same!
5. Clear temporary IE folders, internet Options, and delete temporary and offline files.
6. delete system logs and program logs, my computer/control panel/management tools/Computer Management/Event Viewer/application, right-click/clear events, and clear system logs in sequence
7. Clear system cache: 2000 all files in the system: C: \ WINNT \ system32 \ dllcache
The XP system is: C: \ windows \ system32 \ dllcache all files under the system cache (open my computer/tool/file and Folder Options/hide the protected system file hook off to hide all files on the hook) ). You can also run the sfc.exe/purgecache command to automatically delete the file.
8. Clear the recycle bin
9. delete the files under c: \ windows \ SoftwareDistribution \ Download (the files downloaded when the system is updated are useless if you have installed the updates)
10. Delete all directories under c: \ windows \ RegisteredPackages
11. Delete all Files under C: \ WINDOWS \ Downloaded Program Files
12. view the hidden files that are known to be protected by the system in my computer folder option, and check all the files.
13. Delete c: \ windows \ All files with $8882305 $ (backup files after system update)
Zhidao.baidu.com/question/11035955.html
Zhidao.baidu.com/question/12223613.html
Zhidao.baidu.com/question/14874715.html
... The remaining full text>