1

I have a Win32 application that has a dialog which does certain things only if the process is a restarted process. An outline is as follows:

#define CMDLINE_RESTART_PROCESS "--Restart"

BOOL CheckForProcessRestart()
{
    LPTSTR szCmdLine = ::GetCommandLine()
    return ::StrStr(szCmdLine, CMDLINE_RESTART_PROCESS) != NULL;
}

BOOL CMyDialog::InitInstance()
{
    if(CheckForProcessRestart())
    {
        // Do something (like initialize certain variables, controls, etc)
    }
    // Rest of application
}

After I detect that the process is a restarted one and initialize those controls and variables, my dialog will do its thing and close.

This dialog is accessed by a menu in the main window. On click of that menu button, when this dialog pops up, it will again detect that it is a restarted process because GetCommandLine() will get the original command-line parameters.

My question is, is there any way I can reset the command-line parameters after I handle them?

Thanks!

4

2 に答える 2

3

私の知る限り、これを行う方法はありません。最善の策は、コピーを作成し、常にそのコピーを確認することです。そのコピーは、必要に応じて変更できます。

于 2013-03-04T07:30:13.287 に答える
2

フラグを使用してtrue、最初の再起動時に設定し、その後、チェックして再起動しないでくださいtrue

于 2013-03-04T07:29:00.063 に答える