2010-11-30 95 views
2

壳牌执行具有以下特征:为什么我们需要传递LPCTSTR lpParameters与ShellExecute的

HINSTANCE ShellExecute(
    __in_opt HWND hwnd, 
    __in_opt LPCTSTR lpOperation, 
    __in  LPCTSTR lpFile, 
    __in_opt LPCTSTR lpParameters, 
    __in_opt LPCTSTR lpDirectory, 
    __in  INT nShowCmd 
); 

我们如何使用lpParameters,我们可以处理我的应用程序的参数。我下面执行我的应用程序:

HINSTANCE hShellExecuteStatus = ShellExecute(NULL, "open", "MyPath/MyApp.EXE", NULL, NULL, SW_SHOWNORMAL); 

我可以通过什么的第四个参数即:lpParameters,这样我就可以用MYAPP.EXE解决这个问题,让我们说,如果我传递“喜:在第4 PARAM:

HINSTANCE hShellExecuteStatus = ShellExecute(NULL, "open", "MyPath/MyApp.EXE", "Hi", NULL, SW_SHOWNORMAL); 

我可以检查我的应用程序不管是喜并显示一条消息高

我试着用PostMessage的,但与ShellExecute的有益

回答

2

lpParameters将通过命令行。使用GetCommandLine()来查看它。

+0

我可以只从ShellExecute传递参数,GetCommandLine返回路径和参数 – Simsons 2010-11-30 12:49:15