声明如下:
Private Declare Function GetProcessWorkingSetSize Lib "kernel32" Alias "GetProcessWorkingSetSize" (ByVal hProcess As Long, lpMinimumWorkingSetSize As Long, lpMaximumWorkingSetSize As Long) As LonghProcess是对应进程句柄我搜了一下,但都没有什么合理的解决办法,到底如何使用这个API?  最好有代码举例

解决方案 »

  1.   

    这个没什么好说的,你把进程句柄传进去, lpMinimumWorkingSetSize和lpMaximumWorkingSetSize As Long都是输出的参数:dim lpMinimumWorkingSetSize as long
    dim lpMaximumWorkingSetSize as long
    hProcess=你自己想办法获取(一般就是用openprocess)GetProcessWorkingSetSize hProcess,lpMinimumWorkingSetSize,lpMaximumWorkingSetSize
    msgbox lpMinimumWorkingSetSize
    msgbox lpMaximumWorkingSetSize
      

  2.   

    另外,我感觉你的问题使用GetProcessMemoryInfo这个api函数更合适一些,下面是GetProcessMemoryInfo的说明:
    GetProcessMemoryInfoThe GetProcessMemoryInfo function retrieves information about the memory usage of the specified process.
    BOOL GetProcessMemoryInfo(
      HANDLE Process,
      PPROCESS_MEMORY_COUNTERS ppsmemCounters,
      DWORD cb
    );Parameters
    Process 
    [in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights. For more information, see Process Security and Access Rights. 
    ppsmemCounters 
    [out] Pointer to the PROCESS_MEMORY_COUNTERS or PROCESS_MEMORY_COUNTERS_EX structure that receives information about the memory usage of the process. 
    cb 
    [in] Size of the ppsmemCounters structure, in bytes. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.这个:
    http://www.vbaccelerator.com/home/VB/Tips/Getting_Process_Information_Using_PSAPI/article.asp
    是vb的例子,应该可以满足你的要求