无论如何,是否可以通过 PC 重启或用户单击应用程序快捷方式来识别 MFC 应用程序启动?

Is there anyway to identify that an MFC application is starting by PC rebooting or by user click on application shortcut?

我有一个 MFC 应用程序。此应用程序 运行 PC 重新启动,显然是用户单击应用程序图标。当用户单击应用程序图标时,应用程序将启动这是正常情况。但是如果应用程序 运行 从 PC 重新启动,我想最小化应用程序系统托盘。系统已经实现,但我不知道如何检测应用程序是由PC启动还是用户点击启动。有什么方法可以检测 MFC 应用程序中的这些情况吗?

非常感谢您的帮助。谢谢。

////////////////////////////////////////// ////////////////////////////////

更新: @michael-chourdakis 先生您好,非常感谢您的宝贵建议。我正在下面更新我的解决方案。有人可能会从中得到帮助。

命令行参数值已设置为 "autorun" 并在注册表中使用我的应用程序名称注册此值,如下所示:

CString strFilePath = ApplicationFilePath + _T(" ") + _T("--autorun");

下面是从MFC应用程序获取进程的命令行参数InitInstance:

CString strAutoRun = _T("");

if(AfxGetApp()->m_lpCmdLine != NULL && AfxGetApp()->m_lpCmdLine[0] == _T('[=11=]'))
{
     strAutoRun = AfxGetApp()->m_lpCmdLine;
}

if(strAutoRun.CompareNoCase(_T("--autorun")) == 0)
{
    // Application start from PC Rebooting....  
}

在登录时将应用程序注册到 运行 时(通过注册表、资源管理器启动或您可能使用过的任何其他方法),传递一个命令行参数以通过这种方式指示启动。

并且在应用程序启动时,检查是否使用了该参数。

您可能想要传递一个极值,这样就不会有人在该模式下意外启动您的应用程序,例如 CLSID。