MFC 程序中调用记事本 NotePad 打开 txt 文件

程序如下:

PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
 
STARTUPINFO si;
ZeroMemory (&si, sizeof (STARTUPINFO));     //初始化
si.cb = sizeof (STARTUPINFO);
si.wShowWindow=SW_SHOW;   
si.dwFlags=STARTF_USESHOWWINDOW; 
 
//注意
wchar_t szCmdline[] = _T("C://WINDOWS//notepad.exe D://test.txt");
 
if (::CreateProcess (NULL, szCmdline, NULL,
    NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) {
}

1.STARTUPINFO结构

typedef struct _STARTUPINFO {
  DWORD  cb;
  LPTSTR lpReserved;
  LPTSTR lpDesktop;
  LPTSTR lpTitle;
  DWORD  dwX;
  DWORD  dwY;
  DWORD  dwXSize;
  DWORD  dwYSize;
  DWORD  dwXCountChars;
  DWORD  dwYCountChars;
  DWORD  dwFillAttribute;
  DWORD  dwFlags;
  WORD   wShowWindow;
  WORD   cbReserved2;
  LPBYTE lpReserved2;
  HANDLE hStdInput;
  HANDLE hStdOutput;
  HANDLE hStdError;
} STARTUPINFO, *LPSTARTUPINFO;

2. PROCESS_INFORMATION结构

typedef struct _PROCESS_INFORMATION { 
  HANDLE hProcess;     //进程句柄
  HANDLE hThread;      //进程的主线程句柄
  DWORD dwProcessId;   //进程ID
  DWORD dwThreadId;    //进程的主线程ID
} PROCESS_INFORMATION; 

你可能感兴趣的:(c,struct,null,Class,mfc,border)