[VC]查找当前系统进程及其他常用代码
来源:互联网 发布:securecrt mac 编辑:程序博客网 时间:2024/05/17 23:20
【进程查找】
int counter = 0;
CProcessIterator itp;
//查找系统中应用程序的进程,保证程序只有一个进程在工作
for (DWORD pid=itp.First(); pid; pid=itp.Next()) {
TCHAR modname[_MAX_PATH];
CProcessModuleIterator itm(pid);
HMODULE hModule = itm.First();
if (hModule == NULL) continue;
GetModuleBaseName(itm.GetProcessHandle(), hModule, modname, _MAX_PATH);
if (strcmp (modname, "SEClient.exe") == 0) counter++;
}
if (counter > 1) {
return FALSE;
}
【常用代码】
1: 得到系统时间日期(使用GetLocalTime)
CString sTime,sYear,sMonth,sDay;
SYSTEMTIME CurTime;
GetLocalTime(&CurTime);
sYear.Format("%d年",CurTime.wYear);
sMonth.Format("%d月",CurTime.wMonth);
sDay.Format("%d日",CurTime.wDay);
sTime = sYear+ sMonth + sDay;
// CurTime.wHour
// CurTime.wMinute
// CurTime.wSecond IBM的
AfxMessageBox(sTime);
2: 分离字串
CString str = "4d3f0a2278";
unsigned char a[12];
long x;
for(int i = 0;i< (str.GetLength()/2);i++)
{
sscanf(str.Mid(2*i,2),"%x",&x);
a[i] = x;
}
3: 得到当前目录 (GetCurrentDirectory)
char CurPath[MAX_PATH];
DWORD size=MAX_PATH;
GetCurrentDirectory(size,CurPath);
AfxMessageBox(CurPath);
//
CString number;
int len = LineLength(LineIndex(0));
LPTSTR p=number.GetBuffer(len);
this->GetLine(0,p,len);
AfxMessageBox(number);
得到系统目录 (GetSystemDirectory)
4: 从字符串中提取数字
CString strNum;
CString str("测试125各国87kk");
strNum = GetStr(str);
AfxMessageBox(strNum);
5: 创建无模对话框
CDlg_Test *aa = new CDlg_Test;
aa->Create(IDD_DIALOG1,NULL);
aa->ShowWindow(SW_SHOW);
6: 得到窗口绝对坐标
CString strNum,strNum1;
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
strNum.Format("X: %d",rect.top);
strNum1.Format(" Y: %d",rect.left);
strNum = strNum + strNum1;
AfxMessageBox(strNum);
7: 复制文件夹
SHFILEOPSTRUCT Op;
char FromBuf[]="E://temp/0";
char ToBuf[]="////SINTEKSERVER//个人文档//陈 伟/0";;
Op.hwnd = NULL;
Op.wFunc = FO_COPY;
Op.pFrom = FromBuf;
Op.pTo = ToBuf;
Op.fFlags = FOF_NOCONFIRMATION | FOF_RENAMEONCOLLISION ;
Op.fAnyOperationsAborted = FALSE;
Op.hNameMappings = NULL;
Op.lpszProgressTitle = NULL;
if(SHFileOperation(&Op) == 0)
MessageBox("复制完毕","提示",MB_OK|MB_ICONINFORMATION);
8: 捕获 Ctrl+鼠标左键 组合
case WM_LBUTTONDOWN://鼠标消息wParam ==
if (wParam & MK_CONTROL)
MessageBox(hwnd,"aaa","bbb",MB_OK);
break;
或
case WM_LBUTTONDOWN:
if(GetKeyState(VK_CONTROL)<0)
MessageBox(hwnd,"aaa","bbb",MB_OK);
break;
int counter = 0;
CProcessIterator itp;
//查找系统中应用程序的进程,保证程序只有一个进程在工作
for (DWORD pid=itp.First(); pid; pid=itp.Next()) {
TCHAR modname[_MAX_PATH];
CProcessModuleIterator itm(pid);
HMODULE hModule = itm.First();
if (hModule == NULL) continue;
GetModuleBaseName(itm.GetProcessHandle(), hModule, modname, _MAX_PATH);
if (strcmp (modname, "SEClient.exe") == 0) counter++;
}
if (counter > 1) {
return FALSE;
}
【常用代码】
1: 得到系统时间日期(使用GetLocalTime)
CString sTime,sYear,sMonth,sDay;
SYSTEMTIME CurTime;
GetLocalTime(&CurTime);
sYear.Format("%d年",CurTime.wYear);
sMonth.Format("%d月",CurTime.wMonth);
sDay.Format("%d日",CurTime.wDay);
sTime = sYear+ sMonth + sDay;
// CurTime.wHour
// CurTime.wMinute
// CurTime.wSecond IBM的
AfxMessageBox(sTime);
2: 分离字串
CString str = "4d3f0a2278";
unsigned char a[12];
long x;
for(int i = 0;i< (str.GetLength()/2);i++)
{
sscanf(str.Mid(2*i,2),"%x",&x);
a[i] = x;
}
3: 得到当前目录 (GetCurrentDirectory)
char CurPath[MAX_PATH];
DWORD size=MAX_PATH;
GetCurrentDirectory(size,CurPath);
AfxMessageBox(CurPath);
//
CString number;
int len = LineLength(LineIndex(0));
LPTSTR p=number.GetBuffer(len);
this->GetLine(0,p,len);
AfxMessageBox(number);
得到系统目录 (GetSystemDirectory)
4: 从字符串中提取数字
CString strNum;
CString str("测试125各国87kk");
strNum = GetStr(str);
AfxMessageBox(strNum);
5: 创建无模对话框
CDlg_Test *aa = new CDlg_Test;
aa->Create(IDD_DIALOG1,NULL);
aa->ShowWindow(SW_SHOW);
6: 得到窗口绝对坐标
CString strNum,strNum1;
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
strNum.Format("X: %d",rect.top);
strNum1.Format(" Y: %d",rect.left);
strNum = strNum + strNum1;
AfxMessageBox(strNum);
7: 复制文件夹
SHFILEOPSTRUCT Op;
char FromBuf[]="E://temp/0";
char ToBuf[]="////SINTEKSERVER//个人文档//陈 伟/0";;
Op.hwnd = NULL;
Op.wFunc = FO_COPY;
Op.pFrom = FromBuf;
Op.pTo = ToBuf;
Op.fFlags = FOF_NOCONFIRMATION | FOF_RENAMEONCOLLISION ;
Op.fAnyOperationsAborted = FALSE;
Op.hNameMappings = NULL;
Op.lpszProgressTitle = NULL;
if(SHFileOperation(&Op) == 0)
MessageBox("复制完毕","提示",MB_OK|MB_ICONINFORMATION);
8: 捕获 Ctrl+鼠标左键 组合
case WM_LBUTTONDOWN://鼠标消息wParam ==
if (wParam & MK_CONTROL)
MessageBox(hwnd,"aaa","bbb",MB_OK);
break;
或
case WM_LBUTTONDOWN:
if(GetKeyState(VK_CONTROL)<0)
MessageBox(hwnd,"aaa","bbb",MB_OK);
break;
- [VC]查找当前系统进程及其他常用代码
- 管道、进程及其他
- 枚举系统进程VC代码
- VC获取系统进程列表、查找进程、关闭进程
- 常用函数及其他
- VC从系统进程中查找并杀掉指定进程
- linux下面查看当前端口被哪个进程占用及其他
- [Perl]管道、进程及其他
- [Perl]管道、进程及其他
- [Perl]管道、进程及其他
- VC常用代码之创建进程
- VC++MFC 枚举系统进程核心代码
- VC关闭当前进程
- 四种方法实现VC枚举系统当前进程
- 四种方法实现VC枚举系统当前进程
- 四种方法实现VC枚举系统当前进程
- 四种方法实现VC枚举系统当前进程
- 四种方法实现VC枚举系统当前进程
- JavaScript中escape函数
- 测试相关的书
- ORACLE数据库迁移
- 数据加密类产品深度剖析!
- UML2.0图表一览
- [VC]查找当前系统进程及其他常用代码
- ActiveX控件的开发
- 仿QQ悬挂窗口的实现(全局鼠标钩子)
- Windows多线程多任务设计初步
- 关于ORACLE Statement 对象的数目问题
- Ration rose 破解
- DLL的写法
- Building Google Chrome
- vi实用命令