Updated on 2023-03-23 GMT+08:00

Scenario 13: Exit

Description

When a third-party application exits, the SDK needs to be deinitialized. Otherwise, the HwmSdk.exe process (main process of the Windows SDK) keeps running in the background.

Service Process

To exit the SDK, call the Exit API and then implement the OnExitResult function.

  1. Call the API.

    1. Call the Exit API to exit the SDK.

  2. Implement the callback function.

    Implement the OnExitResult function.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* Exit the SDK.
*/
void CdemoBeforeLoginDlg::OnBnClickedButtonExit()
{
    int ret = hwmsdkagent::Exit();
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        AfxMessageBox(_T("Exit error"));
    }
}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/**
* Exit callback
*/
void demoCallbackProc::OnExitResult(hwmsdk::HwmErrCode ret, const char* msg)
{
    CString codeStr;
    codeStr.Format(_T("%d"), ret);
    string msgStr = CTools::UTF82MultiByte(msg);
    CString tips = _T("OnExitResult code:") + codeStr + _T(", msg:") + CString(msgStr.c_str());
    AfxMessageBox(tips);
}