编译该程序时出现上述标题错误。

   #include <stdio.h>
    #include <windows.h>
    #include <psapi.h>

#define DIV 1048576
#define WIDTH 7


int main(){

     MEMORYSTATUSEX statex;
     statex.dwLength = sizeof (statex);
     GlobalMemoryStatusEx (&statex);

     PERFORMANCE_INFORMATION statex2;
     statex2.cb=sizeof(statex2);
     GetPerformanceInfo(&statex2,statex2.cb);


     FILE *f=fopen("file.txt","w");
     if(f==NULL){
        printf("error opening the file");
        exit(1);
     }
     fprintf(f,"There is  %*ld percent of memory in use.\n",WIDTH, statex.dwMemoryLoad);
     fprintf(f,"There are %*I64d total MB of physical memory.\n",WIDTH, statex.ullTotalPhys/DIV);
     fprintf(f,"There are %*I64d free  MB of physical memory.\n",WIDTH, statex.ullAvailPhys/DIV);

     fprintf(f,"There is %d processes currently in the system",statex2.ProcessCount);

     return 0;


}


这是什么问题?

最佳答案

来自http://msdn.microsoft.com/en-us/library/windows/desktop/ms683210%28v=vs.85%29.aspx


  为了确保正确解析符号,请将Psapi.lib添加到
  TARGETLIBS宏,并使用–DPSAPI_VERSION = 1编译程序。至
  使用运行时动态链接,加载Psapi.dll。

10-04 12:25