win32 api遍历文件,进程

// cmd_mfc.cpp : 定义控制台应用程序的入口点。

#include "stdafx.h"
#include 
#include 
#include 
#include 
#include 
using namespace std;
void enum_process()
{
	HANDLE hProcessSnap=NULL;
	PROCESSENTRY32 pe32={0};
	hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
	if(hProcessSnap==(HANDLE)-1)
	{
		cout<<"CreateToolhelp32Snapshot failed"< dir_list;
	string cdir,subdir;
	WIN32_FIND_DATA wfd;
	HANDLE hfd;
	int r;
	dir_list.push_back(string(cpath));
	while(dir_list.size()) {
		cdir = dir_list.back();
		dir_list.pop_back();
		SetCurrentDirectory(cdir.c_str());
		hfd = FindFirstFile("*.*",&wfd);
		if(hfd!=INVALID_HANDLE_VALUE) {
			do{
				if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{ 
					if(wfd.cFileName[0] != '.') {
						// 合成完整路径名
						subdir=cdir+"\\"+string(wfd.cFileName);
						cout<<"push subdir: "<

你可能感兴趣的:(c/c++)