在C ++中运行外部应用程序的回调

时间:2016-08-08 09:10:56

标签: c++ windows kinect

我正在开发一个Kinect v2应用程序,它在某些时候执行一个与Kinect v2一起使用的外部Unity迷你游戏。我正在使用ShellExecute函数,但我不确定如何在Unity应用程序关闭后实现一个通知主应用程序的回调。我需要它,因为我想在Unity运行自己的主应用程序后暂停主应用程序中的Kinect管理器(否则你可以想象两个Kinect管理器将同时运行)。现在的代码如下:

if (Button->getTag() == "something")
{
    Button->SetActive(false);

    // TODO Pause Kinect manager
    ShellExecute(nullptr,L"open",L"UnityApplication.exe",nullptr,nullptr,SW_SHOWNORMAL);

 // TODO to know once Unity Applications has been closed
 // TODO resume Kinect manager
}

1 个答案:

答案 0 :(得分:2)

使用ShellExecuteEx代替ShellExecute,在SEE_MASK_NOCLOSEPROCESS结构的fMask字段中传递标记SHELLEXECUTEINFO,然后WaitForSingleObjectRegisterWaitForSingleObject hProcess结构的SHELLEXECUTEINFO字段中返回的流程句柄上的<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/thumbnail" android:layout_width="match_parent" android:layout_height="@dimen/album_cover_height" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" android:onClick="clikimage" android:scaleType="fitXY" />