谁能帮我把下面的代码改一下?

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:05:27
这是个老外写的进程监视程序,我用MFC改了一下,我想把StartMonitoring和StopMonitoring两个函数分别放到两个按钮触发的事件中。我把g_AppScope设为全局变量,但总是出错,谁能帮我把它改好?

CMyCallbackHandler myHandler;
CWhatheverYouWantToHold myView;
Perform( &myHandler, &myView );

void CTestDlg::Perform(
CCallbackHandler* pHandler,
CWhatheverYouWantToHold* pParamObject
)
{
//
// Create the only instance of this object
//
CApplicationScope& g_AppScope = CApplicationScope::GetInstance(pHandler);

//
// Initiate monitoring
//
g_AppScope.StartMonitoring(pParamObject);

//
// Terminate the process of observing processes
//
g_AppScope.StopMonitoring();
}

全部源代码可以到这里下载:http://www.codeproject.com/KB/threads/procmon.aspx

CApplicationScope& g_AppScope = CApplicationScope::GetInstance(pHandler);

这个g_AppScope你要设置成全局变量的话,要在CApplicationScope的构造函数里面赋值

帮你问一下我的同学!你等~~~

发过来