PC
VB
运行“Microsoft Visual Studio 2010”。
”vs“的窗口弹出后,找到菜单栏,鼠标左键单击标题为”文件(f)“的选项。
在弹出的列表中鼠标左键单击标题为”新建项目(p)“的项。
在弹出的标题为”新建项目“,鼠标左键选择标题为”Visual Basic“项,在选择标题为”WIndows“的项。再在右边的列表中选择标题为”Windows 窗体应用程序“。再鼠标左键单击标题为”确定“的按钮。
在一个背景为”白色'的窗口,且标题为“ForM1”的窗口中的空白处鼠标左键双击。
在新切换到的“代码编辑页面”的 “Public Class Form1”下写代码: Public Declare Function _优化内存 Lib 'kernel32' Alias 'SetProcessWorkingSetSize' (ByVal hProcess As Integer, ByVal dwMinimumWorkingSetSize As Integer, ByVal dwMaximumWorkingSetSize As Integer) As Integer Public Declare Function _打开当前进程 Lib 'kernel32' Alias 'GetCurrentProcess' () As Integer Public Declare Function _打开进程 Lib 'kernel32' Alias 'OpenProcess' (ByVal 访问级别 As Integer, ByVal 子进程继承 As Integer, ByVal 进程ID As Integer) As Integer
再在“ Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub”下写代码: Private Sub 优化内存(ByVal pid As Integer) Dim 操作句柄 As Integer If pid = -1 Then 操作句柄 = _打开当前进程() End If If pid <> -1 Then 操作句柄 = _打开进程(2035711, 0, pid) End If _优化内存(操作句柄, -1, -1) End Sub
最后在“Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load”下代码:*********************************** 优化内存(6789)***********************************再测试一下就OK喽~!
如果您高兴的的话,就投个票票喽~~
注意API的“接口”是分区大小写的。
注意API的“DLL”要写出来,要不然会程序错误。
注意进制之间的转换。