解决方案 »

  1.   

    指的是 运行参数?MFC程序可以带参数运行的。
      

  2.   

    是运行参数,不过这个参数,需要在MFC中打开文件选择后才可以确定,请问用什么函数可以接受?求具体函数
      

  3.   

    我的理解是ShellExecute可以用于打开另外一个应用程序,使另外一个应用程序获得该运行参数,那本来的exe怎么获得呢?我的参数需要原来的exe读取文件来确定,要用ShellExecute,是不是要关掉原先的exe呢?
      

  4.   

    参数需要原来的exe读取文件来确定,,
    那你的需要创建进程来获取这个exe确定的参数了参考 :VC++实现CMD命令执行与获得返回信息
      

  5.   

    GetCommandLine
    The GetCommandLine function returns a pointer to the command-line string for the current process. LPTSTR GetCommandLine(VOID)
     
    Parameters
    This function has no parameters. Return Values
    The return value is a pointer to the command-line string for the current process. Res
    ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that main and WinMain cannot return Unicode strings is that argc, argv, and lpCmdLine use the LPSTR data type for parameters, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings, because it uses the LPTSTR data type. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Unsupported.
      Header: Declared in winbase.h.
      Import Library: Use kernel32.lib.
      Unicode: Implemented as Unicode and ANSI versions on Windows and Windows NT.See Also
    Processes and Threads Overview, Process and Thread Functions, CreateProcess,WinMain  
      

  6.   

    SetCurrentDirectory
    The SetCurrentDirectory function changes the current directory for the current process. BOOL SetCurrentDirectory(
      LPCTSTR lpPathName   // pointer to name of new current directory
    );
     
    Parameters
    lpPathName 
    Pointer to a null-terminated string that specifies the path to the new current directory. This parameter may be a relative path or a fully qualified path. In either case, the fully qualified path of the specified directory is calculated and stored as the current directory. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
    Each process has a single current directory made up of two parts: A disk designator that is either a drive letter followed by a colon, or a server name and share name (\\servername\sharename) 
    A directory on the disk designator 
    QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Unsupported.
      Header: Declared in winbase.h.
      Import Library: Use kernel32.lib.
      Unicode: Implemented as Unicode and ANSI versions on Windows NT.See Also
    File I/O Overview, File Functions, GetCurrentDirectory  
      

  7.   

    CreateProcess
    The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file. BOOL CreateProcess(
      LPCTSTR lpApplicationName,
                             // pointer to name of executable module
      LPTSTR lpCommandLine,  // pointer to command line string
      LPSECURITY_ATTRIBUTES lpProcessAttributes,  // process security attributes
      LPSECURITY_ATTRIBUTES lpThreadAttributes,   // thread security attributes
      BOOL bInheritHandles,  // handle inheritance flag
      DWORD dwCreationFlags, // creation flags
      LPVOID lpEnvironment,  // pointer to new environment block
      LPCTSTR lpCurrentDirectory,   // pointer to current directory name
      LPSTARTUPINFO lpStartupInfo,  // pointer to STARTUPINFO
      LPPROCESS_INFORMATION lpProcessInformation  // pointer to PROCESS_INFORMATION
    );
    ...
    lpCommandLine 
    Pointer to a null-terminated string that specifies the command line to execute. The system adds a null character to the command line, trimming the string if necessary, to indicate which file was actually used. 
    The lpCommandLine parameter can be NULL. In that case, the function uses the string pointed to by lpApplicationName as the command line. If both lpApplicationName and lpCommandLine are non-NULL, *lpApplicationName specifies the module to execute, and *lpCommandLine specifies the command line. The new process can use GetCommandLine to retrieve the entire command line. C runtime processes can use the argc and argv arguments. If lpApplicationName is NULL, the first white space-delimited token of the command line specifies the module name. If you are using a long filename that contains a space, use quoted strings to indicate where the filename ends and the arguments begin (see the explanation for the lpApplicationName parameter). If the filename does not contain an extension, .EXE is assumed. If the filename ends in a period (.) with no extension, or the filename contains a path, .EXE is not appended. If the filename does not contain a directory path, the system searches for the executable file in the following sequence: The directory from which the application loaded. 
    The current directory for the parent process. 
    Windows 95 and Windows 98: The Windows system directory. Use theGetSystemDirectory function to get the path of this directory.
    Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32. Windows NT: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM. 
    The Windows directory. Use theGetWindowsDirectory function to get the path of this directory. 
    The directories that are listed in the PATH environment variable. 
    If the process to be created is an MS-DOS - based or 16-bit Windows-based application, lpCommandLine should be a full command line in which the first element is the application name. Because this also works well for Win32-based applications, it is the most robust way to set lpCommandLine. 
    ...
      

  8.   

    这个我看了,我就是用这个方法实现的。通过原先exe找到参数,然后重新打开新的exe。但这不是我想要的,我想知道,再不毁坏原先的exe的基础上,能不能让该exe获得运行参数,不要创建新的exe。谢谢