全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3933
推到 Plurk!
推到 Facebook!

Program on calling WinExec to execute Winzip

尚未結案
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-09-16 11:49:38 IP:60.248.xxx.xxx 訂閱
Hi, Sir :

When I run "WinExec('C:\Program Files\Winzip\Winzip32.exe -min -a -r -en C:\Station.zip D:\Temp\*.*', SW_NORMAL);" this code on Delphi V7.0, it always cannot generate the file, Station.zip, on the path c:\, but there is no error showed on screen. Could anybody please teach me how to solve it ? Thank you veyr mcuh !! (Sorry I re-create document here due to I cannot get answer when I created it on the forum for new development)
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-09-16 17:59:51 IP:211.21.xxx.xxx 訂閱
Here is my try and I really got c:\Station.zip.  
I ran on WinXP-P,Delphi7.
Maybe you should check your environment...

[code delphi]
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := 'C:\Program Files\Winzip\Winzip32.exe -min -a -r -en C:\Station.zip c:\Tmp2\*.*';
if WinExec(PChar(Edit1.Text) , SW_NORMAL) > 31 then
ShowMessage('Execute Success');
end;

[/code]

babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-09-16 18:27:22 IP:60.248.xxx.xxx 訂閱
Hi, TWY :

I tried again, but still cannot find station.zip being generated on c:\, do you know how to make winzip to show what it has run ? Thank you veyr mcuh !!
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-09-16 19:39:49 IP:220.132.xxx.xxx 訂閱
Please tell me what's your WinExec return value?
For instance : intReturn = .Text) , SW_NORMAL);
What's the intReturn?


===================引 用 babyfish1998 文 章===================
Hi, TWY :

?? I tried again, but still cannot find station.zip being generated on c:\, do you know how to make winzip to show what it has run ? Thank you veyr mcuh !!
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-09-17 09:26:18 IP:60.248.xxx.xxx 訂閱
Hi, TWY :

The return value is 33, but I don't know what it means, according to your example, it shall mean the executing result is success, Am I right ? But why it cannot generate station.zip ? Thank you very much !!
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#6 引用回覆 回覆 發表時間:2009-09-17 10:34:40 IP:211.21.xxx.xxx 訂閱
According to Win32 help document : 『If the function succeeds, the return value is greater than 31.』
My return value is 33,too. It means the file (WinZip32.exe) exist and execute it well.

I think your problem might comes from your environment, maybe is your WinZip application. Not problem from delphi code.
I also try it as dos command on my PC. It also generated c:\Station.zip as well. You can try it in dos mode to see wherther the problem comes from your environment not delphi...
Here's my command:
『c:\> c:\PROGRA~1\Winzip\Winzip32.exe -min -a -r -en C:\Station.zip c:\Tmp2\*.*』
ps: the version of my WinZip is 8.0 (3105)

babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#7 引用回覆 回覆 發表時間:2009-09-17 10:44:01 IP:60.248.xxx.xxx 訂閱
Hi, TWY :

I tried that command by DOS command mode, it is successful and can generate that file , it is same as what I test before. That is why I feel so strangely. My Winzip is V7.0 and Delphi is V7.0-E. When I executed that code in Delphi, system will popup CPU status window, is it caused this problem ? Thank youveyr mcuh !!
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#8 引用回覆 回覆 發表時間:2009-09-17 10:51:28 IP:211.21.xxx.xxx 訂閱
"system will popup CPU status window" !! That's really weird. It never happened on my PC.
What's your OS? XPP or Vista? (Mine is XPP)
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#9 引用回覆 回覆 發表時間:2009-09-17 11:06:38 IP:60.248.xxx.xxx 訂閱
Hi, TWY :

MY laptop OS is XPP and CPU status window means Debug Windows - CPU. Anything I shall double check again or could you please teach me how to find out the root cause ? Thank you very much !!
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#10 引用回覆 回覆 發表時間:2009-09-17 11:49:24 IP:211.21.xxx.xxx 訂閱
Sorry, I'm not good in tracing CPU debug info. The problem maybe only occur in your environment, you can do the same test in another computer.
I have no any other good idea to you. Maybe somebody else could.

aftcast
站務副站長


發表:81
回覆:1485
積分:1763
註冊:2002-11-21

發送簡訊給我
#11 引用回覆 回覆 發表時間:2009-09-17 13:28:15 IP:210.64.xxx.xxx 訂閱
Hi there,

Once the CPU debuging window shows up, the result will always not as what you expected, that means something wrong and the cause may BEYOND the problem you think. what i wanna say is perphaps, note the winexe line causes it crash, but other line crash be4 run it. could u check it out if it really cause cpu debuging window show up? you can set the break point on winexe that line , then run. if programming not stop at that line and error occurs, that means it doesnt matter with the winexe api and it's parameters.

another suggestion is, if you could paste your code here, that may helps! moreover , upload the error message image, which by printed screen will benefit too.

good luck.

===================引 用 babyfish1998 文 章===================
Hi, TWY :

I tried that command by DOS command mode, it is successful and can generate that file , it is same as what I test before. That is why I feel so strangely.My Winzip is V7.0 and Delphi is V7.0-E. When I executedthat code in Delphi, system will popup CPU status window,is it caused this problem ? Thank youveyr mcuh !!
------


蕭沖
--All ideas are worthless unless implemented--

C++ Builder Delphi Taiwan G+ 社群
http://bit.ly/cbtaiwan
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#12 引用回覆 回覆 發表時間:2009-09-18 10:45:49 IP:60.248.xxx.xxx 訂閱
Hi, aftcast :

Could you please teach me how to post my screen capture files due to I cannot find any upload function once I click "Reply" button ? Thank you very m uch !!
aftcast
站務副站長


發表:81
回覆:1485
積分:1763
註冊:2002-11-21

發送簡訊給我
#13 引用回覆 回覆 發表時間:2009-09-18 11:21:53 IP:210.64.xxx.xxx 訂閱
first, goto https://delphi.ktop.com.tw/board.php?cid=31&fid=130  
at that area, you could post a article with upload picture function. Just put a simple article title and content, for instance, title: picture, content "upload pix", and upload your picture to server.

after posted article, you could see an attached file on article. on attached file icon, right click mouse, and copy its URL.

2nd, go here, and reply the message you wanna let us know. when you edit the reply, please note tool bar above, there's a icon image show hint "Insert/Edit Image". click it and show up a dialog. in that dialog just paste the URL you copied to the URL editbox and click OK.

leave the message what u want and click 發表. Done!

PS. by the way, i wnoder if you could read and understand chinese.?? If u do, may many people can reply in Chinese and help you more.

===================引 用 babyfish1998 文 章===================
Hi, aftcast :

Could you please teach me how to post my screen capture files due to I cannot find any upload function once I click "Reply" button ? Thank you very m uch !!
------


蕭沖
--All ideas are worthless unless implemented--

C++ Builder Delphi Taiwan G+ 社群
http://bit.ly/cbtaiwan
編輯記錄
aftcast 重新編輯於 2009-09-18 11:27:08, 註解 無‧
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#14 引用回覆 回覆 發表時間:2009-09-18 11:47:29 IP:60.248.xxx.xxx 訂閱
Hi, aftcast :

Thank you for your coaching and the following URL can find related screen capture files and hopefully they are useful to you help me to find out the possible reason and solution. Regarding to communicate by Chinese, that is OK to me, but my typing by Chinese is very slow, so I use English. I will try to do by Chinese from next response. Thank you veyr mcuh !!

URL :
aftcast
站務副站長


發表:81
回覆:1485
積分:1763
註冊:2002-11-21

發送簡訊給我
#15 引用回覆 回覆 發表時間:2009-09-18 13:42:04 IP:210.64.xxx.xxx 訂閱
your problem may need take sometime to figure out.   but according to my experience....  it may happened by

1/ your computer infected with virus. Please try to build your project to EXE file. and close delphi. run that exe manually, ie, DO NOT run the project in IDE enviroment. if WITHOUT IDE , it runs well.... that really could be some virus hook system or your ap and cause this problem.

2/ try Tools-> Debugger Options and UN check Integrated debugging。 run again. may solve the problem but.....

do all projects you create and run cause CPU popup ? just curious :-)

PS it's a pity that im well familiar with BCB not delphi. if still not save the problem..... try to upload your project and let dephi user to test it.
Also, i asked if you read Chinese not for reason to ask you type in chinese, but WE could reply with Chinese :P

------


蕭沖
--All ideas are worthless unless implemented--

C++ Builder Delphi Taiwan G+ 社群
http://bit.ly/cbtaiwan
編輯記錄
aftcast 重新編輯於 2009-09-18 13:45:39, 註解 無‧
aftcast 重新編輯於 2009-09-18 13:47:23, 註解 無‧
TWY
高階會員


發表:2
回覆:133
積分:152
註冊:2009-09-02

發送簡訊給我
#16 引用回覆 回覆 發表時間:2009-09-18 15:29:50 IP:211.21.xxx.xxx 訂閱
Try this simple code...
[code delphi]
procedure TForm1.Button1Click(Sender: TObject);
begin
WinExec('C:\WINDOWS\NOTEPAD.EXE', SW_SHOWNORMAL);
end;

[/code]
If you can run well, it means your problem might comes from WinZip32.exe.
If still fail.... Some suggestions...
1. ReInstall Delphi
2. ReInstall OS (like aftcast said, your pc may be infected with virus)

RootKit
資深會員


發表:16
回覆:358
積分:419
註冊:2008-01-02

發送簡訊給我
#17 引用回覆 回覆 發表時間:2009-09-18 17:18:07 IP:61.222.xxx.xxx 訂閱
WinZip Command Line Support Add-on return codes have not been developed to a satisfactory degree. It is often the case that one return code can indicate more than one possibility. Return codes will not be distributed unless or until their reliability has been determined.

WZZIP and WZZUNZIP will in most cases return a nonzero errorlevel in the event of a serious error; otherwise, an errorlevel of 0 is returned. You can use these return codes in batch files and other automated processing.

Piping the details of your command to a log file may be helpful for troubleshooting.

The output from your WinZip Command Line Support Add-On command can be "redirected" to a file for later review. For example, the command:

wzzip -whs -ez -rP filename.zip @listfile.txt > output.log

would produce a text file named output.log containing the information that would normally display in the Command Prompt window if the same command were run manually.

See The WinZIP Support...


RootKit
資深會員


發表:16
回覆:358
積分:419
註冊:2008-01-02

發送簡訊給我
#18 引用回覆 回覆 發表時間:2009-09-18 17:22:39 IP:61.222.xxx.xxx 訂閱
比較好的作法我仍然建議使用一些 VCLZIP 或免費ZIP元件。
一來可掌握明確的是否成功或失敗的訊息,甚至添加進度表。
二來不需要依靠外在的執行檔 WINZIP.EXE。
參考。
babyfish1998
一般會員


發表:3
回覆:7
積分:2
註冊:2009-09-14

發送簡訊給我
#19 引用回覆 回覆 發表時間:2009-09-22 14:19:32 IP:59.124.xxx.xxx 訂閱
Hi, TWY, aftcast and Rootkit :

昨天我tried NOTEPAD.exe , 結果一切正常, 再試Winzip32.exe且不給參數, 系統會show Winzip視窗給我選擇相關設定, 且以防毒軟體scan並未發現病毒, 似乎不是病毒使我無法直接以參數方式產生Zip檔. 但今日再試 WinExec(C:\Program Files\Winzip\Winzip32.exe -min -a -r -en C:\station.zip D:\temp\*.*', SW_NORMAL); 發現會產生station.zip檔, 不知為什麼, 似乎如Rootkit所說, Winzip add-on command line不是十分穩定, 所以我將改用Rootkit所建議的, 改以VCL相關ZIP方式處理. 請問ZipMaster OK嗎? Thank you very much !!
wangccw
一般會員


發表:21
回覆:39
積分:17
註冊:2005-01-30

發送簡訊給我
#20 引用回覆 回覆 發表時間:2009-12-21 17:22:47 IP:210.69.xxx.xxx 訂閱
你可以改用 CreateProcess 試看看,由微軟的文件指出 winexec 已經不建議使用了。
我曾經踩過 winexec 的一些問題,在改用 CreateProcess 之後就正常了,我是不清楚是 winexec 的問題,還是被呼叫程式的問題,
總之你可以試試看 CreateProcess。
系統時間:2024-04-24 8:09:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!