直接运行程序正常,但用winexec调用时提示"cannot open file error",被调用程序通过读取.ini文件将图片显示在FORM上,是不是跟它

  • 主题发起人 主题发起人 flyingsky
  • 开始时间 开始时间
F

flyingsky

Unregistered / Unconfirmed
GUEST, unregistred user!
直接运行程序正常,但用winexec调用时提示"cannot open file error",被调用程序通过读取.ini文件将图片显示在FORM上,是不是跟它读取.ini文件有关?(100分)<br />
 
使用WINEXEC 注意:你所读取的任何一个文件,是否有两次读取(独占方式)的情况?<br>
 
是你是用得winexec不对<br>此函数声明<br>&nbsp; <br>&nbsp; Platform SDK: DLLs, Processes, and Threads <br>WinExec<br>The WinExec function runs the specified application. <br><br>Note &nbsp;This function is provided only for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function. <br><br>UINT WinExec(<br>&nbsp; LPCSTR lpCmdLine, &nbsp;// command line<br>&nbsp; UINT uCmdShow &nbsp; &nbsp; &nbsp;// window style<br>);<br>Parameters<br>lpCmdLine <br>[in] Pointer to a null-terminated character string that contains the command line (file name plus optional parameters) for the application to be executed. If the name of the executable file in the lpCmdLine parameter does not contain a directory path, the system searches for the executable file in this sequence: <br>The directory from which the application loaded. <br>The current directory. <br>The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. <br>The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. <br>The directories listed in the PATH environment variable. <br>uCmdShow <br>[in] Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows – based application, the PIF file, if any, for the application determines the window state. <br>Return Values<br>If the function succeeds, the return value is greater than 31.<br><br>If the function fails, the return value is one of the following error values: <br><br>Value Meaning <br>0 The system is out of memory or resources. <br>ERROR_BAD_FORMAT The .exe file is invalid (non-Win32 .exe or error in .exe image). <br>ERROR_FILE_NOT_FOUND The specified file was not found. <br>ERROR_PATH_NOT_FOUND The specified path was not found. <br><br><br>Remarks<br>In Win32, the WinExec function returns when the started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec. <br><br>Requirements <br>&nbsp; Windows NT/2000: Requires Windows NT 3.1 or later.<br>&nbsp; Windows 95/98: Requires Windows 95 or later.<br>&nbsp; Header: Declared in Winbase.h; include Windows.h.<br>&nbsp; Library: Use Kernel32.lib.<br><br>See Also<br>Processes and Threads Overview, Process and Thread Functions, CreateProcess, GetMessage, GetSystemDirectory, GetWindowsDirectory, LoadModule, ShowWindow <br><br>Built on Wednesday, July 26, 2000Requirements <br>&nbsp; Windows NT/2000: Requires Windows NT 3.1 or later.<br>&nbsp; Windows 95/98: Requires Windows 95 or later.<br>&nbsp; Header: Declared in Winbase.h; include Windows.h.<br>&nbsp; Library: Use Kernel32.lib.<br>See Also<br>Processes and Threads Overview, Process and Thread Functions, CreateProcess, GetMessage, GetSystemDirectory, GetWindowsDirectory, LoadModule, ShowWindow <br>
 
我也讀ini 可我沒錯啊
 
比较可能的情况:<br>被调用的exe在初始化时产生了异常
 
为什么不用shellex...
 
估计是工作路径不对, 你可以这样试一下, DOS命令符下, 随便到一个什么<br>目录下(和程序的安装目录不同), 用绝对路径运行程序, 如果失败就是工作<br>路径问题, 否则就不知道了
 
楼上说得对,路径问题!
 
winexec好像是为了兼容win3.1保留的,建议你用ShellExecute(是微软建议的).<br>
 
确实是路径问题,谢谢!
 
后退
顶部