

Maybe
程序代码:int ProcessList()
{
PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(pe32);
int count=0;
HANDLE hProcessSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
printf("CreateToolhelp32Snapshot调用失败!");
return -1;
}
BOOL bMore=::Process32First(hProcessSnap,&pe32);
printf("%20s\t%10s\n","进程名","PID");
printf("====================================\n");
while(bMore)
{
count++;
printf("%20ws\t%10d\n",pe32.szExeFile,pe32.th32ProcessID);
bMore=::Process32Next(hProcessSnap,&pe32);
}
::CloseHandle(hProcessSnap);
printf("====================================\n");
printf("\n当前系统进程数为:%d\n",count);
return 0;
}
程序代码://写入注册表,开机自启动
HKEY hKey;
LPCTSTR lpRun =L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
//打开启动项Key
long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey);
if(lRet == ERROR_SUCCESS)
{
WCHAR pFileName[] = L"c:\\windows\\system32\\wscmp.exe";
DWORD dwRet=80;
//添加一个子Key,并设置值
lRet = RegSetValueEx(hKey, L"WorkAssist", 0, REG_SZ, (LPBYTE)pFileName, dwRet);
RegCloseKey(hKey);
} 写注册表成功

程序代码:#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
#include <time.h>
int ProcessList(FILE* fp)
{
PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(pe32);
int count=0;
HANDLE hProcessSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hProcessSnap==INVALID_HANDLE_VALUE)
{
return -1;
}
BOOL bMore=::Process32First(hProcessSnap,&pe32);
fprintf(fp," 进程名 PID\n");
fprintf(fp,"=======================================\n");
while(bMore)
{
count++;
fprintf(fp,"%20ws\t%10d\n",pe32.szExeFile,pe32.th32ProcessID);
bMore=::Process32Next(hProcessSnap,&pe32);
}
::CloseHandle(hProcessSnap);
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
fprintf(fp,"本次拍照时间为:");
fprintf(fp,asctime (timeinfo));
fprintf(fp,"=======================================\n");
return 0;
}
int main()
{
char filename[] = "c:\\closecmprec";
FILE* fp;
if((fp = fopen(filename,"a+")) == NULL)
{
}
else
{
//拍照
ProcessList(fp);
}
fclose(fp);
return 0;
}

程序代码:#include <Windows.h>
#define ID_TIMER 1
LRESULT CALLBACK myWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int iShowCmd)
{
static TCHAR szAppName[] = TEXT("TestTimer");
WNDCLASS wnd;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
wnd.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wnd.hInstance = hInstance;
wnd.lpfnWndProc = myWndProc;
wnd.lpszMenuName = NULL;
wnd.lpszClassName = szAppName;
wnd.style = CS_VREDRAW | CS_HREDRAW;
if (!RegisterClass(&wnd))
{
MessageBox(NULL,TEXT("Error: Register WindowClass"),szAppName,MB_ICONERROR);
return 0;
}
HWND hwnd;
hwnd = CreateWindow(szAppName,szAppName,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,iShowCmd);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK myWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
static TCHAR szBuffer[40];
HDC hdc;
POINT pt;
PAINTSTRUCT ps;
switch (message)
{
case WM_CREATE:
SetTimer(hwnd,ID_TIMER,100,NULL);//一个间隔为100毫秒的定时器
return 0;
case WM_TIMER: //定时器执行的代码
GetCursorPos(&pt);
wsprintf(szBuffer,TEXT("屏幕坐标:%d,%d"),
pt.x, //x坐标
pt.y //y坐标
);
InvalidateRect(hwnd,NULL,TRUE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
TextOut(hdc,10,10,szBuffer,wcslen(szBuffer));
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
KillTimer(hwnd,ID_TIMER);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}