rc = WideCharToMultiByte( CP_ACP,0,(LPCWSTR)p,-1,szProcessName,sizeof(szProcessName),NULL,NULL);
// if we cant convert the string then use a default value
if (!rc) strcpy( ProList[i].ProcessName, UNKNOWN_TASK );
else strncpy(ProList[i].ProcessName, szProcessName,sizeof(ProList[i].ProcessName)-1);
// get the process id
pCounter = (PPERF_COUNTER_BLOCK) ((DWORD)pInst + pInst->ByteLength);
ProList[i].dwProcessID = *((LPDWORD) ((DWORD)pCounter + dwProcessIdCounter));
// next process
pInst = (PPERF_INSTANCE_DEFINITION) ((DWORD)pCounter + pCounter->ByteLength);
}
dwRet=i;
}//end of try
__finally
{
if (buf) free( buf );
RegCloseKey( hKeyNames );
RegCloseKey( HKEY_PERFORMANCE_DATA );
if(bRemote)
{
char tmp[52],tmp2[96];
strncpy(tmp,ip,sizeof(tmp)-1);
wsprintf(tmp2,"\\\\%s\\ipccontentquot;,tmp);
WNetCancelConnection2(tmp2,CONNECT_UPDATE_PROFILE,TRUE);
}
}
return dwRet;
}
///////////////////////////////////////////////////////////////////////////////////////
int ConnIPC(char *RemoteName,char *User,char *Pass)
{
NETRESOURCE nr;
char RN[50]="\\\\";
strncat(RN,RemoteName,sizeof(RN)-11);
strcat(RN,"\\ipccontentquot;);
nr.dwType=RESOURCETYPE_ANY;
nr.lpLocalName=NULL;
nr.lpRemoteName=RN;
nr.lpProvider=NULL;
if(WNetAddConnection2(&nr,Pass,User,FALSE)==NO_ERROR)
return 0;
else
return 1;
}
///////////////////////////////////////////////////////////////////////////////////////
void banner()
{
printf("\nPsList ==>Local and Remote process list"
"\nPower by ey4s<ey4s@21cn.com>"
"\nhttp://www.ey4s.org"
"\n2001/6/22\n");
}
/////////////////////////////////////////////////////////////////////////////////////
程序在Windows2000、VC++6.0环境下编译,运行良好。注意哦,远程机器要允许IPC连接和远程操作注册表才可以哦,并且需要Admin权限,编译好的
程序在我的主页http://www.ey4s.org有
下载。