3,245
社区成员
发帖
与我相关
我的任务
分享
HRESULT hr = S_OK;
clearSession();
addNewInfo(_T("Try to connect a device....."));
CoInitialize(NULL);
// Create an instance of the IRAPIDesktop interface.
hr = CoCreateInstance(CLSID_RAPI,
NULL,
CLSCTX_INPROC_SERVER,
IID_IRAPIDesktop,
(void**)&mpIRapiDesktop);
if (hr ==0 && mpIRapiDesktop)
{
addNewInfo(_T("CoCreateInstance success"));
}else{
addNewInfo(_T("CoCreateInstance failure"));
return false;
}
// Call EnumDevices to obtain an enumeration of connected devices.
hr = mpIRapiDesktop->EnumDevices(&mpIRapiEnumDevices);
HRESULT hr = S_OK;
clearSession();
addNewInfo(_T("Try to connect a device....."));
CoInitialize(NULL);
// Create an instance of the IRAPIDesktop interface.
hr = CoCreateInstance(CLSID_RAPI,
NULL,
CLSCTX_INPROC_SERVER,
IID_IRAPIDesktop,
(void**)&mpIRapiDesktop);
if (hr ==0 && mpIRapiDesktop)
{
addNewInfo(_T("CoCreateInstance success"));
}else{
addNewInfo(_T("CoCreateInstance failure"));
return false;
}
// Call EnumDevices to obtain an enumeration of connected devices.
hr = mpIRapiDesktop->EnumDevices(&mpIRapiEnumDevices);
UINT CCESyncDlg::ThreadProc(LPVOID param) //线程函数
{
//数据库的初始化
DBConnectionFactory* pFactory =NULL;
try
{
pFactory=DBConnectionFactory::getIntance();
pFactory->initPool();
}
catch(DatabaseException e)
{
TRACE(e.what());
}
CCESyncDlg* pThread=(CCESyncDlg*)param;
pThread->SyncFun();//实现部分
Sleep(1000);
DBConnectionFactory::releaseInstance();
AfxEndThread(RetThread);
return RetThread;
}
void CCESyncDlg::OnBnClickedSync()
{
// TODO: 在此添加控件通知处理程序代码
ExitCode=0;
m_iThread=AfxBeginThread(ThreadProc,(LPVOID)this);
GetDlgItem(IDC_STOP)->EnableWindow(true);
return ;
}
void CCESyncDlg::OnBnClickedStop()
{
// TODO: 在此添加控件通知处理程序代码
GetDlgItem(IDC_STOP)->EnableWindow(false);
GetDlgItem(IDC_COMEBACK)->EnableWindow(true);
m_iThread->SuspendThread();//挂起线程
}
void CCESyncDlg::OnBnClickedComeback()
{
m_iThread->ResumeThread();//恢复线程
GetDlgItem(IDC_STOP)->EnableWindow(true);
GetDlgItem(IDC_COMEBACK)->EnableWindow(false);
// TODO: 在此添加控件通知处理程序代码
}