7 int PASCAL
WinMain(HINSTANCE hinstCurrent
,
8 HINSTANCE hinstPrevious
,
12 OFSTRUCT SourceOpenStruct1
, SourceOpenStruct2
;
13 char OriginalName
[256], WriteBuf
[256];
14 char FAR
*lpzDestFile
;
16 HFILE hSourceFile
, hDestFile
;
17 /* Most Windows compilers have something like this: */
22 MessageBox((HWND
)NULL
, (LPCSTR
)_ARGV
[1], (LPCSTR
)"_ARGV[1]:", MB_OK
);
23 MessageBox((HWND
)NULL
, (LPCSTR
)_ARGV
[2], (LPCSTR
)"_ARGV[2]:", MB_OK
);
25 hSourceFile
= LZOpenFile(_ARGV
[1], (LPOFSTRUCT
) &SourceOpenStruct1
,
28 wsprintf(WriteBuf
, "Source File Handle: %d\nNo. of args: %d",
30 MessageBox((HWND
)NULL
, (LPCSTR
)WriteBuf
, (LPCSTR
)NULL
, MB_OK
);
32 if ((_ARGC
== 3) && (_ARGV
[2] != NULL
)) lpzDestFile
= _ARGV
[2];
35 lpzDestFile
= OriginalName
;
36 GetExpandedName(_ARGV
[1], lpzDestFile
);
39 MessageBox((HWND
)NULL
, (LPCSTR
)lpzDestFile
, (LPCSTR
)"Destination File",
42 hDestFile
= LZOpenFile(lpzDestFile
, (LPOFSTRUCT
) &SourceOpenStruct2
,
43 OF_CREATE
| OF_WRITE
);
44 wsprintf(WriteBuf
, "Destination File Handle: %d\nNo. of args: %d",
46 MessageBox((HWND
)NULL
, (LPCSTR
)WriteBuf
, (LPCSTR
)NULL
, MB_OK
);
48 dwreturn
= LZCopy(hSourceFile
, hDestFile
);
50 if (dwreturn
== LZERROR_BADINHANDLE
)
51 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_BADINHANDLE\n", (LPCSTR
)NULL
, MB_OK
);
52 if (dwreturn
== LZERROR_BADOUTHANDLE
)
53 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_BADOUTHANDLE\n", (LPCSTR
)NULL
, MB_OK
);
54 if (dwreturn
== LZERROR_BADVALUE
)
55 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_BADVALUE\n", (LPCSTR
)NULL
, MB_OK
);
56 if (dwreturn
== LZERROR_GLOBALLOC
)
57 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_GLOBALLOC\n", (LPCSTR
)NULL
, MB_OK
);
58 if (dwreturn
== LZERROR_GLOBLOCK
)
59 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_GLOBLOCK\n", (LPCSTR
)NULL
, MB_OK
);
60 if (dwreturn
== LZERROR_READ
)
61 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_READ\n", (LPCSTR
)NULL
, MB_OK
);
62 if (dwreturn
== LZERROR_WRITE
)
63 MessageBox((HWND
)NULL
, (LPCSTR
)"LZERROR_WRITE\n", (LPCSTR
)NULL
, MB_OK
);
64 if ((long)dwreturn
> 0L)
65 {wsprintf((LPSTR
)WriteBuf
, (LPCSTR
)"Successful decompression from %s to %s\n",
66 _ARGV
[1], lpzDestFile
);
67 MessageBox((HWND
)NULL
, (LPSTR
)WriteBuf
, (LPCSTR
)NULL
, MB_OK
);
69 LZClose(hSourceFile
); LZClose(hDestFile
);