关于CreateProcess失败193

afairycell 2012-03-27 05:13:10
小弟在window7 32位机下调用函数
PROCESS_INFORMATION pi = { 0 };
STARTUPINFO si = { 0 };
si.cb = sizeof( si );
if(!CreateProcess(
_T("c:\\11.txt"),
NULL, NULL, NULL, FALSE, 0,
NULL, NULL, &si, &pi ))
{
CString str;
str.Format( "CreateProcess failed (%d).\n", GetLastError() );
AfxMessageBox(str);
return;
}

提示是193错误,求解。。以前一直这么用完全没有问题
...全文
2353 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
truexyzflying 2012-03-31
  • 打赏
  • 举报
回复
创建进程需用可执行文件
许文君 2012-03-28
  • 打赏
  • 举报
回复 1
c:\\11.txt ,txt只是一个文本文件,不是有效的win32程序,.txt被关联到notepad.exe,notepad.exe才是有效的win32应用程序
SuperLy 2012-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
你要运行的是打开txt的程序,而不是txt
[/Quote]
比如:
if(!CreateProcess(
_T("notepad c:\\11.txt"),
NULL, NULL, NULL, FALSE, 0,
NULL, NULL, &si, &pi ))
afairycell 2012-03-28
  • 打赏
  • 举报
回复
ShellExecute(NULL, _T("open"), _T("c:\\11.txt"), NULL, NULL, SW_SHOW);

这个可以实现,为什么CreateProcess不行呢?
afairycell 2012-03-28
  • 打赏
  • 举报
回复
创建一个进程打开这个TXT文件,理论上是可以的,不知道为什么会有这个提示。。应该怎么使用这个函数?
Lactoferrin 2012-03-27
  • 打赏
  • 举报
回复
你要运行的是打开txt的程序,而不是txt
oyljerry 2012-03-27
  • 打赏
  • 举报
回复
GetLastError is 193 ( is not a valid win32 applicaltion)
hotpos 2012-03-27
  • 打赏
  • 举报
回复

ShellExecute(NULL, _T("open"), _T("c:\\11.txt"), NULL, NULL, SW_SHOW);


Win7 懒了吧

15,474

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧