Lhaz
cabsfx.h
[詳解]
1 /*==========================================================================*/
2 /* CabSfx インストーラ kb@chitora.jp */
3 /*==========================================================================*/
4 #ifndef _KBINSTALLER_H
5 #define _KBINSTALLER_H
6 
7 #include <windows.h>
8 #include <vector>
9 #include "fdi.h"
10 #include "mystr.h"
11 #include "lhazsfx.h"
12 #include "lhazshellex.h"
13 #include "lhazarc.h"
14 
15 using namespace std;
16 
17 class KBINSTALLER {
18 public:
19  enum { SFX_START = WM_USER, DISP_NAME, FINISH };
20  enum {
21  LHAZWND_WIDTH = 256,
22  LHAZWND_HEIGHT = 114,
23  };
24  //
26  static DWORD SkipSize;
27  static long coffFiles;
28  static vector<long> coffCabstart;
29  //
30  static bool ReadByte(HANDLE hFile, char& d);
31  static bool ReadStr(HANDLE hFile, MYSTR& d);
32  //
33  KBINSTALLER(HINSTANCE hins, LPTSTR lpCmdLine);
34  ‾KBINSTALLER(void);
35  HWND GetHwnd(void) const { return Hwnd; }
36  bool GetStop(void) const { return Stop; }
37  const TCHAR* GetExeName(void) const { return ExeName; }
38  int Run(void);
39  void Progress(unsigned int size);
40  void ConvDelim(char* path, char delim);
41  bool SetFileTime(const MYSTR& name, WORD date, WORD time);
42  int DoOverWrite(const MYSTR& name);
43  INT_PTR NextCab(PFDINOTIFICATION pfdin);
44 
45 private:
46  class CFHEADER {
47  public:
48  CFHEADER(void);
49  ‾CFHEADER(void);
50  bool Get(HANDLE hFile);
51  //
52  char signature[4];
53  long reserved1;
54  long cbCabinet;
55  long reserved2;
56  long coffFiles;
57  long reserved3;
60  short cFolders;
61  short cFiles;
62  short flags;
63  short setID;
64  short iCabinet;
65  unsigned short cbCFHeader;
66  char cbCFFolder;
67  char cbCFData;
68  char* abReserve;
70  MYSTR szDiskPrev;
72  MYSTR szDiskNext;
73  private:
74  static const unsigned short cfhdrPREV_CABINET;
75  static const unsigned short cfhdrNEXT_CABINET;
76  static const unsigned short cfhdrRESERVE_PRESENT;
77  };
78  //
79  class CFFOLDER {
80  public:
81  CFFOLDER(void);
82  ‾CFFOLDER(void);
83  bool Get(HANDLE hFile, unsigned char cbCFFolder);
85  short cCFData;
86  short typeCompress;
87  char* abReserve;
88  };
89  //
90  class CFFILE {
91  public:
92  CFFILE(void);
93  ‾CFFILE(void);
94  bool Get(HANDLE hFile);
95  long cbFile;
97  short iFolder;
98  short date;
99  short time;
100  short attribs;
101  MYSTR szName;
102  static const unsigned short ifoldCONTINUED_FROM_PREV;
103  static const unsigned short ifoldCONTINUED_TO_NEXT;
104  static const unsigned short ifoldCONTINUED_PREV_AND_NEXT;
105  };
106  //
107  static const TCHAR CLASSNAME[];
108  static const TCHAR SFXTITLE[];
109  static const char HEADER[4];
110 #ifdef FEATURE_LHAZ
111  static const TCHAR LHAZEXT[];
112  static const TCHAR LHAZVIEW[];
113  static const TCHAR LHAZOPEN[];
114  static const TCHAR LHAZARC[];
115  static const int SKIPSIZE;
116  static const TCHAR LHAZVERNUM[];
117 #endif
118  //
119  static bool Initialized;
120  static HINSTANCE Instance;
121  //
122  static bool IsSJIS_First(unsigned char c) {
123  return ((c >= 0x80) && ((c < 0xA0) || (c >= 0xE0) && (c < 0xFD)));
124  }
125  //
126  HWND Hwnd;
127  HWND StaticWnd;
128  HWND PrgrsWnd;
130  LONGLONG Total;
131  LONGLONG Melted;
133  unsigned int Pos;
134  HANDLE Thread;
135  bool Force;
136  bool Skip;
137  bool Stop;
138  MYSTR DestDir;
139  bool Option;
140  TCHAR ExeName[MAX_PATH];
143 #ifdef INSTALLER
144  bool Kanren;
145  bool KanrenZ;
146  bool KanrenC;
147  bool KanrenT;
148  bool KanrenA;
149  bool KanrenG;
150  bool KanrenB;
151  bool Kanren2;
152  bool KanrenR;
153  bool KanrenTXZ;
154  bool KanrenXZ;
155  #ifdef FEATURE_7ZIP
156  bool Kanren7;
157  #endif // FEATURE_7ZIP
158  bool ConView;
159  bool ConComp;
160  bool RddComp;
161  static const TCHAR LZHEXT[];
162  static const TCHAR ZIPEXT[];
163  static const TCHAR CABEXT[];
164  static const TCHAR TGZEXT[];
165  static const TCHAR TAREXT[];
166  static const TCHAR GZIPEXT[];
167  static const TCHAR TBZEXT[];
168  static const TCHAR BZ2EXT[];
169  static const TCHAR TXZEXT[];
170  static const TCHAR XZEXT[];
171  static const TCHAR RAREXT[];
172  #ifdef FEATURE_7ZIP
173  static const TCHAR SZIPEXT[];
174  #endif // FEATURE_7ZIP
175  static const TCHAR LHAZARCHIVELZH[];
176  static const TCHAR LHAZARCHIVEZIP[];
177  static const TCHAR LHAZARCHIVECAB[];
178  static const TCHAR LHAZARCHIVETGZ[];
179  static const TCHAR LHAZARCHIVETAR[];
180  static const TCHAR LHAZARCHIVEGZIP[];
181  static const TCHAR LHAZARCHIVETBZ[];
182  static const TCHAR LHAZARCHIVEBZ2[];
183  static const TCHAR LHAZARCHIVETXZ[];
184  static const TCHAR LHAZARCHIVEXZ[];
185  static const TCHAR LHAZARCHIVERAR[];
186  #ifdef FEATURE_7ZIP
187  static const TCHAR LHAZARCHIVE7ZIP[];
188  #endif // FEATURE_7ZIP
189  static const TCHAR LHAZREG[];
190 #endif // INSTALLER
191  //
192  static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
193  static INT_PTR CALLBACK DialogOverWrite(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
194  static INT_PTR CALLBACK DialogNextCab( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
195  static INT_PTR CALLBACK DialogMain( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
196  static DWORD WINAPI ExtractThread(LPVOID pv);
197  //
198  bool Init(HINSTANCE hins, LPTSTR lpCmdLine);
199  bool Start(void);
200  DWORD GetSfxSize(HANDLE hFile);
201  LONGLONG GetTotal(HANDLE hFile);
202  bool Extract(void);
203  bool ChangeDir(const MYSTR& dir);
204  void CreateShortCut(void);
205 #ifndef FEATURE_LHAZ
206  void SetReg(void);
207 #endif // !FEATURE_LHAZ
208 #ifdef FEATURE_LHAZ
209  bool GetParam(HANDLE hFile);
210 #ifdef INSTALLER
211  void GetCmdLine(LPTSTR lpCmdLine);
212  void GetReg(void);
213  bool GetReg(LPCTSTR subkey, const TCHAR* data);
214  void SetReg(void);
215  void SetReg(LPCTSTR subkey, const TCHAR* data, ARCHIVE::TYPE type, const TCHAR* old);
216  void DeleteShortCut(int);
217  bool CheckLatestVersion(void);
218 #endif // INSTALLER
219  void Exec(void);
220 #endif // FEATURE_LHAZ
221  bool Read(HANDLE hFile, MYSTR& d, int size);
222 
223 };
224 
225 #endif // _KBINSTALLER_H
static const unsigned short ifoldCONTINUED_FROM_PREV
Definition: cabsfx.h:102
Archive.
TYPE
Definition: lhazarc.h:28
char versionMinor
Definition: cabsfx.h:58
MYSTR szDiskPrev
Definition: cabsfx.h:70
MYSTR DestDir
Definition: cabsfx.h:138
long coffFiles
Definition: cabsfx.h:56
LHAZSFX Param
Definition: cabsfx.h:141
MYSTR szCabinetPrev
Definition: cabsfx.h:69
char versionMajor
Definition: cabsfx.h:59
HWND StaticWnd
Definition: cabsfx.h:127
static const unsigned short ifoldCONTINUED_TO_NEXT
Definition: cabsfx.h:103
unsigned int Pos
Definition: cabsfx.h:133
static const unsigned short cfhdrPREV_CABINET
Definition: cabsfx.h:74
static bool Initialized
Definition: cabsfx.h:119
long cbFile
Definition: cabsfx.h:95
MYSTR szDiskNext
Definition: cabsfx.h:72
short cFolders
Definition: cabsfx.h:60
HWND Hwnd
Definition: cabsfx.h:126
short cCFData
Definition: cabsfx.h:85
MYSTR szCabinetNext
Definition: cabsfx.h:71
LHAZSHELLEX ShellEx
Definition: cabsfx.h:142
HWND GetHwnd(void) const
Definition: cabsfx.h:35
bool Skip
Definition: cabsfx.h:136
Definition: cabsfx.h:90
const TCHAR * GetExeName(void) const
Definition: cabsfx.h:37
static HINSTANCE Instance
Definition: cabsfx.h:120
LONGLONG Melted
Definition: cabsfx.h:131
HANDLE Thread
Definition: cabsfx.h:134
short cFiles
Definition: cabsfx.h:61
Definition: cabsfx.h:46
long cbCabinet
Definition: cabsfx.h:54
Definition: lhazshellex.h:11
short flags
Definition: cabsfx.h:62
short typeCompress
Definition: cabsfx.h:86
static const unsigned short cfhdrRESERVE_PRESENT
Definition: cabsfx.h:76
short time
Definition: cabsfx.h:99
unsigned short cbCFHeader
Definition: cabsfx.h:65
short attribs
Definition: cabsfx.h:100
HWND CancelButtonWnd
Definition: cabsfx.h:129
Definition: lhazsfx.h:10
short setID
Definition: cabsfx.h:63
bool Stop
Definition: cabsfx.h:137
bool m_silent_install
Definition: cabsfx.h:132
short date
Definition: cabsfx.h:98
bool GetStop(void) const
Definition: cabsfx.h:36
static const unsigned short cfhdrNEXT_CABINET
Definition: cabsfx.h:75
Definition: cabsfx.h:17
static vector< long > coffCabstart
Definition: cabsfx.h:28
long uoffFolderStart
Definition: cabsfx.h:96
static KBINSTALLER * Installer
Definition: cabsfx.h:25
bool Force
Definition: cabsfx.h:135
long coffCabstart
Definition: cabsfx.h:84
long reserved3
Definition: cabsfx.h:57
static const unsigned short ifoldCONTINUED_PREV_AND_NEXT
Definition: cabsfx.h:104
long reserved2
Definition: cabsfx.h:55
char * abReserve
Definition: cabsfx.h:87
long reserved1
Definition: cabsfx.h:53
static long coffFiles
Definition: cabsfx.h:27
char cbCFData
Definition: cabsfx.h:67
MYSTR szName
Definition: cabsfx.h:101
bool Option
Definition: cabsfx.h:139
Definition: cabsfx.h:79
char * abReserve
Definition: cabsfx.h:68
static bool IsSJIS_First(unsigned char c)
Definition: cabsfx.h:122
HWND PrgrsWnd
Definition: cabsfx.h:128
short iFolder
Definition: cabsfx.h:97
static DWORD SkipSize
Definition: cabsfx.h:26
short iCabinet
Definition: cabsfx.h:64
char cbCFFolder
Definition: cabsfx.h:66
LONGLONG Total
Definition: cabsfx.h:130