• 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;
    	}
    

      

  • 相关阅读:
    MarkDownPad2 注册码
    如何让你的.vue在sublime text 3 中变成彩色?
    字典树入门
    博弈论
    复杂度问题
    gets scanf以及缓冲区域的问题
    对象
    矩阵转置的一般算法
    二叉树的建立、遍历、叶子节点计数、深度计算
    D
  • 原文地址:https://www.cnblogs.com/horane/p/3090474.html
Copyright © 2020-2023  润新知