d00_ape Posted September 3, 2004 Share Posted September 3, 2004 I want to run this file C:\gzip.exe like I do in the prompt: gzip.exe -9 C:\myfile.wrl How can I make the call with the parameters ?-9? and ?C:\myfile.wrl? ? Link to comment Share on other sites More sharing options...
0 _tux_ Posted September 3, 2004 Share Posted September 3, 2004 (edited) could use the WinExec API. The WinExec function runs the specified application. This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function. UINT WinExec( LPCSTR lpCmdLine, // address of command line UINT uCmdShow // window style for new application ); Parameters lpCmdLine Points to a null-terminated character string that contains the command line (filename 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, Windows searches for the executable file in this sequence: 1. The directory from which the application loaded. 2. The current directory. 3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. 4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. 5. The directories listed in the PATH environment variable. uCmdShow 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. Return Values If the function succeeds, the return value is greater than 31. If the function fails, the return value is one of the following error values: Value Meaning 0 The system is out of memory or resources. ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image). ERROR_FILE_NOT_FOUND The specified file was not found. ERROR_PATH_NOT_FOUND The specified path was not found. Remarks Win32-based applications should use the CreateProcess function rather than this function. The WinExec function exists in Win32 to provide compatibility with earlier versions of Windows. For more information about how the WinExec function is implemented, see the Remarks section of the LoadModule function. 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. This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function. ho hum :) never used that before. but winexec works fine for me :) Edited September 3, 2004 by _tux_ Link to comment Share on other sites More sharing options...
0 bithub Posted September 3, 2004 Share Posted September 3, 2004 Use ShellExecute(), or ShellExecuteEx(). Link to comment Share on other sites More sharing options...
0 John Veteran Posted September 3, 2004 Veteran Share Posted September 3, 2004 First of all, what language are you using? :huh: Link to comment Share on other sites More sharing options...
0 smurfiness Posted September 4, 2004 Share Posted September 4, 2004 First of all, what language are you using? :huh: Doesn't really matter. Any Windows programming language will let you call an API function. Link to comment Share on other sites More sharing options...
0 Ultra Frosty Posted September 6, 2004 Share Posted September 6, 2004 in C , you can use: system("gzip.exe -9 C:\myfile.wrl"); Link to comment Share on other sites More sharing options...
0 bangbang023 Veteran Posted September 6, 2004 Veteran Share Posted September 6, 2004 Doesn't really matter. Any Windows programming language will let you call an API function. Um it does matter because VB won't accept C++ code, Java won't accept BASIC, and so on and so forth. Link to comment Share on other sites More sharing options...
0 gigapixels Veteran Posted September 6, 2004 Veteran Share Posted September 6, 2004 Doesn't really matter. Any Windows programming language will let you call an API function. It could very well be Java... So it kind of does matter... Link to comment Share on other sites More sharing options...
0 smurfiness Posted September 6, 2004 Share Posted September 6, 2004 Um it does matter because VB won't accept C++ code, Java won't accept BASIC, and so on and so forth. *sigh* Well yes obviously it would have to be translated. But no, the language of the example doesn't matter, because it's a Windows API function. And if the poster can't figure out how to call an API function in his/her programming language of choice, then what language the example is in is probably even LESS relevant; programming lessons would seem to be a bigger priority. It could very well be Java... So it kind of does matter... True, but then the poster didn't specify, and hasn't come back to specify, so really, s/he'll just have to take whatever is offered. Link to comment Share on other sites More sharing options...
Question
d00_ape
I want to run this file C:\gzip.exe like I do in the prompt:
gzip.exe -9 C:\myfile.wrl
How can I make the call with the parameters ?-9? and ?C:\myfile.wrl? ?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts