473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Shell Compressed Folder

Hello,

I'm having a trouble with a Shell.Folder object when I'm trying to use it
from a C++ application, but at the same time, the same object works fine
from within html script.

The effect is that, I cannot put data into a compressed folder in C++, in
spite of the fact that all operations succeed.

Note: all this have to work under XP and above, because of integrated
compressed folder shell object.

I appreciate any hint to a what causes this behavior.

It is given:
c:\temp\data.txt - any text file.
c:\temp\data.zip - empty zip file
(compress data.txt manualy, and then remove it from within zip).

C++ program:
---
#import <shell32.dll> named_guids
#include <iostream>

class CoInit
{
public:
CoInit() { CoInitialize(0); }
~CoInit() { CoUninitialize(); }
};

bool CompressFile()
{
try
{
Shell32::IShellDispatchPtr shell(Shell32::CLSID_Shell);
Shell32::FolderPtr destinationFolder =
shell->NameSpace(L"c:\\temp\\data.zip");

if (destinationFolder == 0)
return false;

if (destinationFolder->MoveHere(L"c:\\temp\\data.txt") != S_OK)
return false;

return true;
}
catch(const _com_error &e)
{
std::cout << e.ErrorMessage() << std::endl;

return false;
}
}

int main(int argc, char* argv[])
{
CoInit coInit;
bool result = CompressFile();

std::cout << (result ? "succeed" : "failed") << std::endl;

return 0;
}

---

Html file:
---
<html>
<head>
<script type="text/javascript" language="javascript">

function doClick()
{
var shell = new ActiveXObject("Shell.Application");
var folder = shell.NameSpace("c:\\temp\\data.zip");

if (folder == null)
return false;

folder.MoveHere("c:\\temp\\data.txt");

return true;
}

</script>
</head>
<body>
<button onclick="doClick()">Click me</button>
</body>
</html>
---

Thanks.
--
Vladimir Nesterovsky
e-mail: vl******@nesterovsky-bros.com
home: http://www.nesterovsky-bros.com



Nov 17 '05 #1
4 4553
> I'm having a trouble with a Shell.Folder object when I'm trying to use it
from a C++ application, but at the same time, the same object works fine
from within html script.

The effect is that, I cannot put data into a compressed folder in C++, in
spite of the fact that all operations succeed.

Note: all this have to work under XP and above, because of integrated
compressed folder shell object.

I appreciate any hint to a what causes this behavior.


Well, I've figured out what happens. Shell32::Folder::MoveHere works in an
asynchronous way. This means that operation returns immediately with succeed
code if all parameters are correct, however the actual work is performed
later in a separate thread. This way C++ application exits before it
actually
started the work, and html application succeeds as it's continue running.
Unfortunately, I have found no an easy way to get completion event.

After all, it must be not the easiest way to compress files from the
application. Therefore my question for now is how would I create zip from my
unmanaged application?
--
Vladimir Nesterovsky
e-mail: vl******@nesterovsky-bros.com
home: http://www.nesterovsky-bros.com
Nov 17 '05 #2
Vladimir Nesterovsky wrote:
I'm having a trouble with a Shell.Folder object when I'm trying to
use it from a C++ application, but at the same time, the same object
works fine from within html script.

The effect is that, I cannot put data into a compressed folder in
C++, in spite of the fact that all operations succeed.

Note: all this have to work under XP and above, because of integrated
compressed folder shell object.

I appreciate any hint to a what causes this behavior.


Well, I've figured out what happens. Shell32::Folder::MoveHere works
in an asynchronous way. This means that operation returns immediately
with succeed code if all parameters are correct, however the actual
work is performed later in a separate thread. This way C++
application exits before it actually
started the work, and html application succeeds as it's continue
running. Unfortunately, I have found no an easy way to get completion
event.

After all, it must be not the easiest way to compress files from the
application. Therefore my question for now is how would I create zip
from my unmanaged application?


ZLIB is your friend (it's what the shell uses under the covers).

http://www.zlib.net/

-cd
Nov 17 '05 #3
> I'm having a trouble with a Shell.Folder object when I'm trying to use it
from a C++ application, but at the same time, the same object works fine
from within html script.

The effect is that, I cannot put data into a compressed folder in C++, in
spite of the fact that all operations succeed.

Note: all this have to work under XP and above, because of integrated
compressed folder shell object.

I appreciate any hint to a what causes this behavior.


Well, I've figured out what happens. Shell32::Folder::MoveHere works in an
asynchronous way. This means that operation returns immediately with succeed
code if all parameters are correct, however the actual work is performed
later in a separate thread. This way C++ application exits before it
actually
started the work, and html application succeeds as it's continue running.
Unfortunately, I have found no an easy way to get completion event.

After all, it must be not the easiest way to compress files from the
application. Therefore my question for now is how would I create zip from my
unmanaged application?
--
Vladimir Nesterovsky
e-mail: vl******@nesterovsky-bros.com
home: http://www.nesterovsky-bros.com
Nov 17 '05 #4
Vladimir Nesterovsky wrote:
I'm having a trouble with a Shell.Folder object when I'm trying to
use it from a C++ application, but at the same time, the same object
works fine from within html script.

The effect is that, I cannot put data into a compressed folder in
C++, in spite of the fact that all operations succeed.

Note: all this have to work under XP and above, because of integrated
compressed folder shell object.

I appreciate any hint to a what causes this behavior.


Well, I've figured out what happens. Shell32::Folder::MoveHere works
in an asynchronous way. This means that operation returns immediately
with succeed code if all parameters are correct, however the actual
work is performed later in a separate thread. This way C++
application exits before it actually
started the work, and html application succeeds as it's continue
running. Unfortunately, I have found no an easy way to get completion
event.

After all, it must be not the easiest way to compress files from the
application. Therefore my question for now is how would I create zip
from my unmanaged application?


ZLIB is your friend (it's what the shell uses under the covers).

http://www.zlib.net/

-cd
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: R.Marquez | last post by:
I just happened to bump into this today when I went to the Win32 Python Extensions page. I think the M.H. and his team are a bit too modest. Quote: "win32com.shell grows many more interfaces,...
2
by: lauren quantrell | last post by:
Using the Windows RUN/Open window I can enter the following to open the application and have it directed to my specified folder: "C:\Program Files\MyAPplication.exe" "C:\Documents and...
4
by: Pavel | last post by:
Hello. I am trying to make a folder compressed and failing miserably. Below are three ways that I tried to make it compressed, all of them compile and run w/o any problems, but the folder is...
0
by: Vladimir Nesterovsky | last post by:
Hello, I'm having a trouble with a Shell.Folder object when I'm trying to use it from a C++ application, but at the same time, the same object works fine from within html script. The effect...
3
by: JP | last post by:
I have an app that represents ShellFolder Items as a visual element (listview item, etc). The code correctly performs Drag&Drop operations EXCEPT in the case when the item being dragged is from a...
2
by: Nathan | last post by:
I'd like to create a simple backup utility for myself, which would involve selecting a group of files and sending them to a compressed folder in WinXP. Can someone point me in the right direction...
3
by: Justin Busch | last post by:
I thought I saw an article online about programmatically using the Send To Compressed (zipped) Folder function in VB, however that page no longer exists. Does anyone have details on how this is...
2
by: mravichandran | last post by:
dear Readers, i will be downloading a zip file from the intranet website programmatically and i would like to process some of the files inside them before the user can save it. we have a lot of...
11
by: MadMonk | last post by:
Hi, I need to write a small Windows application (console or forms) (for Windows XP SP2 & Windows Server 2003), which will check a folder for the presence of some files, and if they exist, it...
3
by: ppuniversal | last post by:
Hi everyone, I am making using Shell() function to run a command line tool from my VB Application. I am using it to archive a folder. So I am using the code : Shell("command line argument as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.