This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Windows file compression
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 20, 2010
04:44 AM
Windows file compression
How am i able to detect if a file is compressed via windows file compression?
I know there exists an attribute on ntfs file systems but am not able to retrieve this piece of information via GetFileInfo in custom actions.
Any ideas how to achieve this?
mary
I know there exists an attribute on ntfs file systems but am not able to retrieve this piece of information via GetFileInfo in custom actions.
Any ideas how to achieve this?
mary
(10) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 20, 2010
10:39 AM
... hm maybe call a dll ? ...
no idea? :confused:
mary
no idea? :confused:
mary
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
01:18 AM
nobody a solution - I am sure not the only one with this problem, right? 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
02:37 AM
why do you want to detect if the file is compressed, just uncompress it every time with compact /U /S /I "C:\file.txt"
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
03:05 AM
well - usually i want to execute functions only if necessary...
my situation is as follows:
while updating sql databases (alter tables etc), sometimes they are compressed and my updates fails - i want to check actually BEFORE updating wether the databases are compressed.
then i would have to stop the sql server which maybe shuts down other apps ...
mary
my situation is as follows:
while updating sql databases (alter tables etc), sometimes they are compressed and my updates fails - i want to check actually BEFORE updating wether the databases are compressed.
then i would have to stop the sql server which maybe shuts down other apps ...
mary
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
07:51 AM
sure this is not sexy, but I don't know an IS function that shows you the status of the file.
The comapct.exe included in Windows works fine for such operations, it doesn't create errors if the file is not compacted.
LaunchAppAndWait(WINSYSDIR ^ "compact.exe", "/U /I "+TARGETDIR ^ "SQLDB.MDF", WAIT|LAAW_OPTION_HIDDEN);
helps me to prevent errors with compacted SQL DBs.
If you have to check the file status before you use compact.exe you may be use a Windows dll function.
Like this:
------------------------------------------------------------------------------
prototype int Kernel32.GetFileAttributes(string);
export prototype BOOL IsFileCompressed(string);
function BOOL IsFileCompressed(filename)
int attributes, nResult;
begin
nResult = UseDLL(WINSYSDIR ^ "Kernel32.dll");
if(nResult != 0) then
MessageBox("Unable to load " + WINSYSDIR ^ "Kernel32.dll.", SEVERE);
exit;
endif;
attributes = GetFileAttributes(filename);
UnUseDLL(WINSYSDIR ^ "Kernel32.dll");
return (attributes & 0x800) == 0x800;
end;
------------------------------------------------------------------------------
and call:
if(IsFileCompressed("C:\\Temp\\test.txt")) then
//decompress file
endif;
The comapct.exe included in Windows works fine for such operations, it doesn't create errors if the file is not compacted.
LaunchAppAndWait(WINSYSDIR ^ "compact.exe", "/U /I "+TARGETDIR ^ "SQLDB.MDF", WAIT|LAAW_OPTION_HIDDEN);
helps me to prevent errors with compacted SQL DBs.
If you have to check the file status before you use compact.exe you may be use a Windows dll function.
Like this:
------------------------------------------------------------------------------
prototype int Kernel32.GetFileAttributes(string);
export prototype BOOL IsFileCompressed(string);
function BOOL IsFileCompressed(filename)
int attributes, nResult;
begin
nResult = UseDLL(WINSYSDIR ^ "Kernel32.dll");
if(nResult != 0) then
MessageBox("Unable to load " + WINSYSDIR ^ "Kernel32.dll.", SEVERE);
exit;
endif;
attributes = GetFileAttributes(filename);
UnUseDLL(WINSYSDIR ^ "Kernel32.dll");
return (attributes & 0x800) == 0x800;
end;
------------------------------------------------------------------------------
and call:
if(IsFileCompressed("C:\\Temp\\test.txt")) then
//decompress file
endif;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
11:45 AM
thanks for your reply - my approach is quite similar
as a workaround i also thought about using compact in combination with findstr to get the result in only one line and then parse this line to extract the number of compressed files.
but i would do this only if i can't use the GetFileAttributeEx function in kernel32.dll
Any idea how to call it or should i try your little example first?
i must confess - i'll give it a try after the weekend 😉
mary
as a workaround i also thought about using compact in combination with findstr to get the result in only one line and then parse this line to extract the number of compressed files.
but i would do this only if i can't use the GetFileAttributeEx function in kernel32.dll
Any idea how to call it or should i try your little example first?
i must confess - i'll give it a try after the weekend 😉
mary
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 28, 2010
07:58 AM
@MrTree:
thanks for your brief example - obviously i didn't read any further last week. 😮
It does exactly what i want!
thanks again :rolleyes:
mary
thanks for your brief example - obviously i didn't read any further last week. 😮
It does exactly what i want!
thanks again :rolleyes:
mary
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 31, 2010
03:57 AM
... just to make everything right:
i don't have to load and unload kernel32.dll, right?!
mary
i don't have to load and unload kernel32.dll, right?!
mary
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 08, 2010
09:48 AM
mary_v wrote:
... just to make everything right:
i don't have to load and unload kernel32.dll, right?!
mary
that's right, cause every Windows Programm even InstallShield needs/loads kernel32.dll.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 08, 2010
12:05 PM
Right, the UseDLL help topic mentions not needing to load and unload that and other system DLLs.
![](/skins/images/CC38E504FC9E1309DC48ACFEB4925670/responsive_peak/images/icon_anonymous_message.png)