zoukankan      html  css  js  c++  java
  • CreateProcess导致内存权限异常

    使用UNICODE字符集的时候,MSDN有如此描述:

    BOOL WINAPI CreateProcess(
      _In_opt_     LPCTSTR lpApplicationName,
      _Inout_opt_  LPTSTR lpCommandLine,
      _In_opt_     LPSECURITY_ATTRIBUTES lpProcessAttributes,
      _In_opt_     LPSECURITY_ATTRIBUTES lpThreadAttributes,
      _In_         BOOL bInheritHandles,
      _In_         DWORD dwCreationFlags,
      _In_opt_     LPVOID lpEnvironment,
      _In_opt_     LPCTSTR lpCurrentDirectory,
      _In_         LPSTARTUPINFO lpStartupInfo,
      _Out_        LPPROCESS_INFORMATION lpProcessInformation
    );
    

    The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.

    lpCommandLine要传入可修改的内存。

    	wchar_t cmdline[] = L"/c ping localhost > d:\pingres.log";
    	if (!CreateProcess(L"c:\\windows\\system32\\cmd.exe", cmdline
    		,NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi)) {
    			MessageBox(L"Error on CreateProcess()");
    			return;
    	}
    

      

  • 相关阅读:
    显示AVI的第一桢
    视频采集,存成avi
    视频捕获
    如何将Wav文件做到EXE文件里
    图形整体拉出效果
    3.2 指数型生成函数
    3.1 普通型生成函数
    诡异的楼梯 HDU
    A strange lift HDU
    胜利大逃亡 HDU
  • 原文地址:https://www.cnblogs.com/horane/p/3090474.html
Copyright © 2011-2022 走看看