2007-12-12
出處:pcdog.com //
程序描述資訊
typedef struct _tagprocessinfo
processinfo, *lpprocessinfo;//
獲取程序資訊列表
bool enumprocessesinfo( processinfo* lppsinfo, ulong ulsize, ulong* pulneeded )
// lppsinfo [out] :
指向processinfo
結構陣列的指標
// nsize [in] : lppsinfo
中的元素個數
// nneeded [out] :
實際的元素個數
// 返回值
: true :
成功; false :
失敗lpdwpids = (lpdword)heapalloc( getprocessheap(), 0, dwbsize2 );
if( lpdwpids == null )
if( ! ::enumprocesses( lpdwpids, dwbsize2, &dwbsize ) )
}while( dwbsize == dwbsize2 ) ;
ulong ulcount = dwbsize / sizeof( dword );
//如果為詢問數量,則返回實際數量
if ( null == lppsinfo && 0 == ulsize )
assert( lppsinfo );
if ( null == lppsinfo )
if ( ulsize <= ulcount )
else
//獲得程序資訊
handle hprocess;
hmodule hmodule;
dword dwsize;
char path_buffer[_max_path];
char drive[_max_drive];
char dir[_max_dir];
char fname[_max_fname];
char ext[_max_ext];
// loop through each procid.
for( ulong ulindex = 0 ; ulindex < (*pulneeded) ; ulindex++ )
else if ( 8 == lpdwpids[ulindex] )
// open process and get process infomation
hprocess = openprocess(
process_query_information | process_vm_read,
false, lppsinfo[ulindex].dwpid );
if( hprocess != null )
}closehandle( hprocess ) ;}}
return true;}
方法二void cemnuprocessdlg::listprocess()
while(process32next (hprocesssnap,&pe32));
}else
closehandle (hprocesssnap);}
注:在stdafx加入所用到的標頭檔案tlhelp32.h
獲得當前程序的列表(原始碼)
程序描述資訊 typedef struct tagprocessinfo processinfo,lpprocessinfo 獲取程序資訊列表 bool enumprocessesinfo processinfo lppsinfo,ulong ulsize,ulong pulneeded lppsi...
獲得當前程序名
用快照取得當前的程序名,下面是測試小例子。include 需要匯入tlhelp32.h moduleentry32 mcurprocessmodule32 mcurprocessmodule32.dwsize sizeof moduleentry32 最好手動初始化,因為會取前4位元組作為長度。ha...
獲得當前ViewController
easy ti get your current view controller in display 使你的view controller 繼承自 baseviewcontroller make your viewcontroller inheritance baseviewcontroller ...