0
int sysReturn = system("\"C:\\Program Files\\WinZip\\winzip32\" -a C:\\LOG\\test.zip C:\\LOG\\LOG_7-20-2010_17_8_48_834.csv");  

Everything seems to work - as in it creates test.zip
However, it opens the WinZip GUI (that shows how much has been compressed, etc while my program is running.)

How can I skip that part where it doesn't open anything in windows that the user sees? I would like it to be "hidden" so after my program runs, all you see is the zipped file.

WinZip command line parameters reference:
http://www.memecode.com/docs/winzip.html

T.T.T.
  • 33,367
  • 47
  • 130
  • 168
  • 8
    **Please**, no. What if your user doesn't have WinZip? What if the computer is 64-bit? What if there is no `C:` drive? (Like three of my machines) – SLaks Jul 21 '10 at 17:14
  • This is going on a controlled system where I know exactly where WinZip is, etc. Not for general use. – T.T.T. Jul 21 '10 at 17:16
  • I know guys but I can't bring in any open source compression library.... – T.T.T. Jul 21 '10 at 17:25
  • 2
    It sounds like he's developing an app for "In house" use in a company. Some companies Will Not allow open source for fear it will "taint" their stuff. Just like most big companies are still using IE6 and WinXP SP2 – Caladain Jul 21 '10 at 17:35
  • @Caladain, even so, if you have that mentality, you can still write your own library properly, without hitting executables. – Salgar Jul 21 '10 at 17:37
  • @ Salgar: schedule and budget. If it was up to me I would have used zlib... – T.T.T. Jul 21 '10 at 17:47
  • @Caladain - "still using IE6 and WinXP" ....exactly. – T.T.T. Jul 21 '10 at 17:49
  • What will it take to convince the company that open-source is not poison? – SLaks Jul 21 '10 at 17:50
  • @SLaks: Great question, if you find out let me know. – T.T.T. Jul 21 '10 at 17:51
  • Well, part of the issue is the GPL. I love the GPL. All my coding outside of work is GPL. But Some big companies have been "bit" by including open source components in their stuff. (rightfully so btw). But this made them afraid of the GPL "contaminating" their whole code base. It's fear, and it's very hard to dislodge. I've found the best way is to do it "slowly"..little baby steps and fighting the good fight in the meeting rooms as to why you're right and it's safe. – Caladain Jul 21 '10 at 18:30

6 Answers6

3

Your code is very wrong.

To create .zip files, you should use a native .zip library in C++.

Here are some free ones:

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
3

How about stop using the winzip executable from your c++ code and use a library instead? For your code to ever have any hope of working on a different system, you can't rely on 3rd party executables being around.

Have a look at this: portable zip library for C/C++ (not an application)

Community
  • 1
  • 1
Salgar
  • 7,687
  • 1
  • 25
  • 39
3

I'd agree with the other's answers about using a different utility. However, to answer your question: the link that you posted also mentions another option -min to run WinZip minimized. Did you try that? Also, instead of using system, try using ShellExecute and ask for the window to be hidden:

ShellExecute(NULL, NULL, "C:\\Program Files\\WinZip\\winzip32", "-a C:\\LOG\\test.zip C:\\LOG\\LOG_7-20-2010_17_8_48_834.csv", NULL, SW_HIDE);
casablanca
  • 69,683
  • 7
  • 133
  • 150
  • Is there a way to hide the confirmation box without checking "do not display again"? this does hide the WinZip GUI but not the confirm box that shows the stats of the compression with the OK button. – T.T.T. Jul 21 '10 at 18:13
  • I'm afraid that's not possible, unless there's a command-line option to disable that. – casablanca Jul 21 '10 at 18:27
2

You want this:

http://www.winzip.com/prodpagecl.htm

1

Can you use 7-zip? It is free (LGPL license) and can be run from the command line without creating a window.

zdan
  • 28,667
  • 7
  • 60
  • 71
1

Try using execlp instead. The few times i've had to do it i had better luck with it over System.

execlp("explorer", "/n, /select,c:\\foo.txt", 0)

See this MSDN page for a detailed example: http://msdn.microsoft.com/en-us/library/431x4c1w.aspx

Caladain
  • 4,801
  • 22
  • 24