-
June 19th, 2011, 03:11 PM
#1
trouble with Irfanview command line option
I have a program that is looped, and in the loop it takes in user input to determine which image to open with Irfanview. My problem is that when I open the program with Irfanview, my program halts until I close that image that Irfanview opened up. The user input is based on facial features constantly taken in from a webcam, so it isn't a keyboard not being on the correct window issue. When the image is closed, the program starts again as usual, until another image is opened, whereupon it halts again.
Anyone have any idea?
Also, I should add that my program runs just fine if I exit the window of my program and open Irfanview and load an image manually. It only screws up with the command line option
i_view32.exe c:\blarg.bmp /fs
-
June 19th, 2011, 03:16 PM
#2
Re: trouble with Irfanview command line option
Originally Posted by Ragnarok22788
Also, I should add that my program runs just fine if I exit the window of my program and open Irfanview and load an image manually.
What do you mean by "manually"? Did you go to the command-line and start IrfanView with the command-line you say doesn't work in your program? Or did you just click on IrfanView and go to "File/Open" or whatever menu option is used to load a file? If you did the latter, then that is not the test you should be doing.
Secondly, are you sure that your program doesn't, for some reason, mess up the command-line being sent to IrfanView, and you're just assuming you're sending a proper command?
Last, what API call did you use to start IrfanView? If it's a Windows API call, then you need to redirect your question to the Windows API forum, as possibly you are not using the correct functions to start the program.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; June 19th, 2011 at 03:18 PM.
-
June 19th, 2011, 03:35 PM
#3
Re: trouble with Irfanview command line option
Originally Posted by Paul McKenzie
What do you mean by "manually"? Did you go to the command-line and start IrfanView with the command-line you say doesn't work in your program? Or did you just click on IrfanView and go to "File/Open" or whatever menu option is used to load a file? If you did the latter, then that is not the test you should be doing.
Secondly, are you sure that your program doesn't, for some reason, mess up the command-line being sent to IrfanView, and you're just assuming you're sending a proper command?
Last, what API call did you use to start IrfanView? If it's a Windows API call, then you need to redirect your question to the Windows API forum, as possibly you are not using the correct functions to start the program.
Regards,
Paul McKenzie
I'm a novice programmer, so I'll try to be as thorough as possible.
My software allows me to open images with command line options in a separate command prompt. I cannot physically type into the command prompt associated with my program as it never gives me the option to.
I am sure the command-line being sent to IrfanView is correct because it is a hard coded string that successfully opens an image when I use it in a system call in my program
system("\"c:\\program files\\irfanview\\i_view32.exe\" c:\\blarg.bmp /fs")
The IrfanView commands are documented here
http://www.robvanderwoude.com/files/iviewcli.txt
Also, I am not starting the program, which I never knew could be an issue. If I am in a command prompt, the command
"c:\program files\irfanview\i_view32.exe" c:\blarg.bmp /fs
automatically opens the image in the program, even if there is no instance of IrfanView running.
I hope this clarifies things further. Thanks for your help!
-
June 19th, 2011, 03:50 PM
#4
Re: trouble with Irfanview command line option
Last edited by S_M_A; June 19th, 2011 at 03:54 PM.
-
June 19th, 2011, 03:51 PM
#5
Re: trouble with Irfanview command line option
Originally Posted by Ragnarok22788
I'm a novice programmer, so I'll try to be as thorough as possible.
My software allows me to open images with command line options in a separate command prompt.
when I use it in a system call in my program
Are you using the system() function? If you're running Windows, you should be using CreateProcess(), and not the watered down system() function call.
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Regards,
Paul McKenzie
-
June 20th, 2011, 02:14 PM
#6
Re: trouble with Irfanview command line option
Thanks! I've got the windows coming up and working well now, but I've been stuck on my destroywindow() issue this morning. Though I have ShellExecute create a new process and open the image and immediately calling getConsoleWindow, destroyWindow doesn't seem to be destroying the window.
I am sure that my getConsoleWindow is getting a window because it never comes back with null, so the HWND I pass to destroyWindow should destroy a window, but nothing is closing on my screen. Any ideas?
My code is
ShellExecute(NULL,"open","c:\\program files\\irfanview\\i_view32.exe","c:\\image1.bmp",NULL,SW_SHOW);
HWND hConsoleWnd = GetConsoleWindow();
if(hConsoleWnd == NULL)
{printf("failed attempt.\n");}
DestroyWindow(hConsoleWnd);
I'll be looking into CreateProcess in the mean time, since it looks like a better option than ShellExecute, but I figured out how to use ShellExecute first, which is why I used it.
-
June 20th, 2011, 02:27 PM
#7
Re: trouble with Irfanview command line option
Look at CreateProcess, and the last parameter (LPPROCESS_INFORMATION). This will return you a handle you can use to interact with the newly created process. GetConsoleWindw does not return the console associated with the new process. It gets the console related to the current process.
Viggy
-
June 21st, 2011, 03:10 PM
#8
Re: trouble with Irfanview command line option
I couldn't find a way to use LPPROCESS_INFORMATION to kill the window (CloseHandle wasn't doing the trick for some reason), so I resorted to doing a taskkill system call for Irfanview. It works well enough for my purposes, though I feel that using LPPROCESS_INFORMATION's process handle to close Irfanview's window would be a lot nicer. How is that done?
-
June 22nd, 2011, 06:53 AM
#9
Re: trouble with Irfanview command line option
Originally Posted by Ragnarok22788
I couldn't find a way to use LPPROCESS_INFORMATION to kill the window (CloseHandle wasn't doing the trick for some reason)
Did you read the documentation on CloseHandle? Where does it say that this should "kill the window"?
The 'nice' way to close the window would be to get the main window from the process information and send a WM_CLOSE message to that window.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|