C++怎么调用matlab生成的exe程序

遥新 2014-03-28 10:34:45
我有一个用matlab生成的exe程序,用C++语句
ShellExecute(NULL,_T("open"),"E:\\...\\a.exe",NULL,NULL,SW_SHOW);
调用时,每次执行程序都会卡住,然后显示说无反应,关闭程序。我用这个程序能调用其他的exe程序,但是matlab生成的那个不行,请问怎么才能实现呢?
...全文
365 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶子大丹 2015-12-03
  • 打赏
  • 举报
回复
我是初学这个的,请问我生成一个matlab exe文件后,直接在c++builder程序中些下这个 ShellExecute(NULL,_T("open"),"E:\\...\\a.exe",NULL,NULL,SW_SHOW)就可以吗?头文件其他的都不用设置吗
遥新 2014-04-04
  • 打赏
  • 举报
回复
解决了,是程序中某些文件路径格式没设置好。
ithiker 2014-03-29
  • 打赏
  • 举报
回复
matlab生成exe程序???在我的印象中好像还没有这么生成过,外部程序要调用matlab程序有专门的方法,google下!
遥新 2014-03-29
  • 打赏
  • 举报
回复
继续等待高手支招啊。
遥新 2014-03-29
  • 打赏
  • 举报
回复
引用 1 楼 yiyefangzhou24 的回复:
程序本身有问题吧,双击能打开?
程序没问题的,双击能打开,下面这堆英文没太能看明白,试了那个初始化语句没能起作用,惆怅。
遥新 2014-03-29
  • 打赏
  • 举报
回复
没人碰到过类似问题吗?
yiyefangzhou24 2014-03-29
  • 打赏
  • 举报
回复
Remarks Because ShellExecuteEx can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations) that are activated using Component Object Model (COM), COM should be initialized before ShellExecuteEx is called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here: CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE) There are instances where ShellExecuteEx does not use one of these types of Shell extension and those instances would not require COM to be initialized at all. Nonetheless, it is good practice to always initalize COM before using this function. When DLLs are loaded into your process, you acquire a lock known as a loader lock. The DllMain function always executes under the loader lock. It is important that you do not call ShellExecuteEx while you hold a loader lock. Because ShellExecuteEx is extensible, you could load code that does not function properly in the presence of a loader lock, risking a deadlock and therefore an unresponsive thread. With multiple monitors, if you specify an HWND and set the lpVerb member of the SHELLEXECUTEINFO structure pointed to by lpExecInfo to "Properties", any windows created by ShellExecuteEx might not appear in the correct position. If the function succeeds, it sets the hInstApp member of the SHELLEXECUTEINFO structure to a value greater than 32. If the function fails, hInstApp is set to the SE_ERR_XXX error value that best indicates the cause of the failure. Although hInstApp is declared as an HINSTANCE for compatibility with 16-bit Windows applications, it is not a true HINSTANCE. It can be cast only to an int and can be compared only to either the value 32 or the SE_ERR_XXX error codes. The SE_ERR_XXX error values are provided for compatibility with ShellExecute. To retrieve more accurate error information, use GetLastError. It may return one of the following values.
yiyefangzhou24 2014-03-29
  • 打赏
  • 举报
回复
程序本身有问题吧,双击能打开?

64,636

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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