How to pack-back a chm file that was unpacked by 7zip - compression

According to the 7zip documentation, the formats that 7zip supports are:
Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
Unpacking only: AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z.
I wanted to ask, if I use 7zip to unpack a chm file. How can I pack it back?
I see that 7zip does not support this, so who does?
I would like to take the files that 7zip unpacked (from the chm file) and create back a CHM file.
Is that possible?

If you have only the CHM file, there is no easy way to do this and you need reverse-engineering like mentioned by #Mark.
So you have to decompile the CHM file and compile again by HTML Help Workshop - a free CHM compiler created by Microsoft many years ago - or by another help authoring tool.
Edit 2023-01-11:
I've archived a copy of the HTML Help Workshop installer
Microsoft HTML Help Downloads (the download links are broken and dropped by Microsoft)
If you really want to start with Reverse Engineering a first step of decompiling is described at HTMLHelp command-line. Search for: Example of using HH.EXE to decompile a CHM help file.
You know, you can use 7Zip or just open a command prompt window on a Windows PC and type the following:
hh.exe -decompile <target_directory> <path>\<filename>.chm
The only decompiler with any additional features is KeyTools as this can try to rebuild the project (.hhp) file. You'll need this file if you want to recompile the help project.
One thing to note is that the decompile/recompile process isn't a "round-trip" process. Certain features that the help author added to the original help file can't be recovered when you decompile it, so these may no longer work properly after you've recompiled.
This is especially true in the area of context-sensitive help, which may be broken in the new version of the file.

Only if you have some internal Microsoft utility to do that, since that is their proprietary format, or you write your own using information from reverse-engineering the format.

Related

Is it possible to add a version number to a file that will be visible in Properties/Details in windows explorer

I have an unmanaged C++ project where I am writing data to a custom file format that I have defined.
What I would like to know is if there is a way to add a header that is compatible with Windows Explorer so that a version number will be displayed, as in the example below showing a Windows font.
The purpose of this is so that non-tech savvy users could simply right click and identify the version of the file, without having to open it in Notepad etc.
Any help would be appreciated.
Tom
You cannot achieve this for a file in general. But if your file format stores a version information, you can teach the Windows Explorer to display it.
You have to write a Shell Extension for the Explorer, that can extract arbitrary information out of your files. This extension must be installed on the target computer and registered in the registry.
An excellent guide on how to write and register Shell Extensions can be found here on CodeProject. (Part VIII should cover what you need)
The version information comes from VERSIONINFO resource, attached to a binary file, such as .EXE or .DLL. So it is easy to link such resource into your build target, this resource is also editable.
However, this is limited to the binary executable files, and you cannot attach this resource information to arbitrary files (as you wanted), including such as text files.
In VC just go to menu Project->AddResource and pick Version.

Find out the mime type and associated applications with Qt

How can I find out a mime-type or content-type of a given file?
I cannot use the suffix because the file could be renamed.
Possible additions would be categorizing them as jpg, gif, png and so on are image files and can be opened by editing applications, which has been set in the OS.
Thank you in advance.
What platform? On *nix, you should refer to how the program file does it, which is based on a few heuristics including checks of the first few bytes of a file (many file formats start with a fixed header, including many image formats).
If you're on Windows, the *nix file command is probably still instructive, even if you can't reuse its code as directly. There may also be some better solution in the Windows APIs (I'm not a Windows programmer).
This could help, it is with C# but I think you can get the idea.
http://kseesharp.blogspot.com/2008/04/c-get-mimetype-from-file-name.html
You can use some sort of class for acccesing Windows Registry from qt or using the Windows API directly from qt.
I am not a qt programmer.
You can't, not from within Qt.
However, if all you want is to show a file with the correct application, you can use QDesktopServices::openUrl(), which wraps open (Windows/OSX) and xdg-open (Unix). The URL may also be a local file (in that case, use QUrl::fromLocalFile() to construct the URL).
For categorizing image files. For Qt and just only for image files.
QByteArray imageFormat = QImageReader::imageFormat(fileName); //Where fileName - path to your file
Further mapping imageFormat to mime-type is not complicable
It doesn't look like Qt offers that capability yet. However, you may want to look into the libmagic library which does what the file and other similar commands do. Assuming the library is maintained properly it will include new MIME types as time passes. From what I can tell it is part of the file tool suite. Under a Debian system do something like this:
sudo apt-get install libmagic-dev
to get the development library and use #include to make use of it.

How do I use the 7z sdk to extract rar/zip files (C++)?

I'm trying to write a small, cross-platform comic book reader (Qt / C++). I don't care what's already out there, I know there are some.
My problem is that I need to read the comic book formats, which are renamed rar and zip files.
The documentation is very... nonexistent? There's no "hello archive" document anywho.
How can I set this up?
If It makes it easier to assume I'm on any particular OS, do so. I'm switching between Kubuntu, OSX, and Win7 constantly for dev work.
I've been working on a simple C++ wrapper for the 7zip SDK, which you can find here. It currently only supports Windows and the specific needs I had, but I'd be happy to make some alterations and/or accept contributions. It can extract 7zip and Zip files in a few lines of code, using the 7z.dll. RAR shouldn't be difficult to add since the DLL supports it.
7z should actually come with both source for a commandline variant and a GUI variant, you could dig into to those and see how they do the compression, else you could use unRar and see if that has any examples(unfortunatly I can't check due to the download being blocked where I am).
Poking around the LMZA SDK a bit I came across this:
ANSI-C LZMA Decoder
~~~~~~~~~~~~~~~~~~~
Please note that interfaces for ANSI-C
code were changed in LZMA SDK 4.58. If
you want to use old interfaces you can
download previous version of LZMA SDK
from sourceforge.net site.
To use ANSI-C LZMA Decoder you need
the following files:
1) LzmaDec.h + LzmaDec.c + Types.h
LzmaUtil/LzmaUtil.c is example
application that uses these files.

What libraries should I use to manipulate archives from C++?

I want to manipulate .zip and .rar files from C++. What libraries should I use?
The zlib library comes with a sample showing how you can use it with .zip files (I think it's called "minizip" or something, though I haven't had much experience with it personally).
RAR is a bit difference, since it's basically proprietary. I don't know if there's any libraries that can do it.
zlib and minizip, yes. minizip was last updated in 2005. Some facts about version 1.01e:
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g, WinZip, InfoZip tools and compatible.
Multi volume ZipFile (span) are not supported.
Encryption compatible with pkzip 2.04g only supported
Old compressions used by old PKZip 1.x are not supported
boost::iostreams also is a good choice.
Open Source Ogre3d has implementation of zip decompressor, you can read it.
Codeka is correct in recommending zlib, but if you're on Windows, you might want to take a look at ZipUtils, which is zlib repackaged with a simpler interface and a few bells and whistles added.

How to configure Vim for C++ development?

I'm learning C++ using Vim as an editor on Windows XP, however I found a issue that I have listed below.
I have downloaded and installed c.vim and it is a essential file, however when I start vim it shows the message C/C++ template file 'C:\Program Files\Vim\vimfiles\c-support/templates/Templates' does not exist or is not readable, How do i fix this problem?
How would i make vim compile a C++ STL file?
For your first problem: I suspect that you didn't extract all the files in the archive (that c.vim came in). The c.vim documentation (README.csupport) says:
The subdirectories in the zip archive
cvim.zip mirror the directory
structure which is needed below the
local installation directory
$HOME/.vim/ for LINUX/UNIX
($VIM/vimfiles/ for Windows)
This means that you need to uncompress the entire archive as it is into your vimfiles directory.
There are some other steps to follow, detailed in the documentation.
As for your second issue: you need a Makefile to do that. If you have never done this before, I suggest using cmake to generate a Makefile. You will also need GNU tools for Windows; Cygwin or MinGW are the most popular choices. I haven't use them, it is easier to do all this on some *nix OS :).
When done, use :cd (if you are not in your working directory), and :make. Use :cl to list the compiler output, :cn to jump to the next error. There are some other useful commands for compiling. You might find these resources useful:
StackOverflow: Recommended plugins for C coding
Compiling from Vim
C editing with Vim
Also, I found the Nerd Commenter a very useful companion.
I found that Vim acts somewhat like alien on Windows; it is designed for an *nix-like operating system. I think it is possible to craft a similar environment for it, and use it mostly successfully, but it is so much easier to do on some linux, as it is "instantly home" there.
Anyway, if you wish to stick with Windows, I think you can find a way to accomplish what you want. Good luck.
Download Vim and install to your computer.
Download c.vim and extract to $Vim\vimfiles\
Download MinGW and install to your computer, make sure that you check C++ Compiler at Select Components.
Add C:\MinGW to system Path variable
Edit _vimrc file, add set makeprg=mingw32-make after line behave mswin
Test your Vim with hello world, use !g++ c:\full_path\filename.cpp -o c:\full_path\output.exe.