如何获得进程自己的名称? RT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用toolhelp函数族先CreateToolhelp32Snapshot然后Process32First得到 PROCESSENTRY32 结构 TCHAR sFilename[MAX_PATH];GetModuleFileName(AfxGetInstanceHandle(), sFilename, MAX_PATH);sFilename中即是本进程的完整路径名称 const int MAX_SIZE = 100;extern HWND g_hWndFind[MAX_SIZE];extern int g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>HWND g_hWndFind[MAX_SIZE];int g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>>static BOOL WINAPI EnumWindowsProc(HWND hWnd, LPARAM lParam);>>>>>>>>>>>>>>>>>>>>>>>>>>BOOL CDlg::EnumWindowsProc(HWND hWnd, LPARAM lParam){ if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE) { g_hWndFind[g_iWndIndex] = hWnd;//record the HWND handle into array g_iWndIndex++;//count start } return TRUE;}>>>>>>>>>>>>>>>>>>>>>>>>>>>> m_strList.ResetContent(); ::EnumWindows(CEmulateWindowDlg::EnumWindowsProc,NULL); HWND hProcess = NULL; TCHAR chClassName[MAX_PATH]; for(int i = 0; i < g_iWndIndex; i++) { TCHAR tcName[MAX_PATH]; hProcess = g_hWndFind[i]; ::GetWindowText(hProcess,tcName,MAX_PATH); m_strList.AddString(tcName); } ZeroMemory(&g_hWndFind,sizeof(g_hWndFind)); g_iWndIndex = 0; 一个比较棘手的问题,求高手出马! 如何实现数据库自动换行? 一个制作透明窗体的问题(30分) 如何实现两个不同工程窗口控件的拷贝? 各位大虾 SHGetFolderPath的问题!! 我的图片怎么就不见了呢 ? 如何在InstallShield中使用 MSXML3.DLL 提供的接口函数。以及其他相关问题,请进来看看(100分) 有谁了解DNP协议,进来看看 怎样把VC的文本控件做成透明的,可以显示背景图片 这里问下,还有多少人搞MFC呢? 如何利用Mutex实现应用程序的单实例运行 绝对路径
先CreateToolhelp32Snapshot
然后Process32First
得到 PROCESSENTRY32 结构
extern int g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>
HWND g_hWndFind[MAX_SIZE];
int g_iWndIndex;>>>>>>>>>>>>>>>>>>>>>>>>>>>static BOOL WINAPI EnumWindowsProc(HWND hWnd, LPARAM lParam);>>>>>>>>>>>>>>>>>>>>>>>>>>
BOOL CDlg::EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE)
{
g_hWndFind[g_iWndIndex] = hWnd;//record the HWND handle into array
g_iWndIndex++;//count start
}
return TRUE;
}>>>>>>>>>>>>>>>>>>>>>>>>>>>> m_strList.ResetContent();
::EnumWindows(CEmulateWindowDlg::EnumWindowsProc,NULL); HWND hProcess = NULL;
TCHAR chClassName[MAX_PATH];
for(int i = 0; i < g_iWndIndex; i++)
{
TCHAR tcName[MAX_PATH];
hProcess = g_hWndFind[i];
::GetWindowText(hProcess,tcName,MAX_PATH);
m_strList.AddString(tcName);
}
g_iWndIndex = 0;