home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 4
/
BUGCD1997_05.BIN
/
aplic
/
clip4win
/
clip4win.exe
/
C4W30E.HUF
/
SOURCE
/
LZFUNCS.PRG
< prev
next >
Wrap
Text File
|
1994-11-08
|
2KB
|
90 lines
////////////////////////////
//
// Clip-4-Win LZ functions demo
//
// Copyright (C) 1994 Skelton Software, Kendal Cottage, Hillam, Leeds, UK.
// All Rights Reserved.
//
// Compile: LZfuncs /n /w
// Link: /se:600 LZfuncs,,,clip4win,clip4win.def
//
////////////////////////////
#include "windows.ch"
#include "openfile.ch"
#define nstr(i) alltrim(str(i))
static hWnd
static cAppName := "Clip-4-Win"
function main()
local nEv
hWnd = WinSetup(cAppName, "Clip-4-Win LZ functions demo")
do while .t.
do while (nEv := ChkEvent()) == EVENT_NONE
enddo
do case
case nEv == EVENT_REDRAW
@ 5,2 say "Note: whenever you run COMPRESS.EXE, think about using /R"
@ 9,2 say "Hit SPACE..."
case nEv == EVENT_KEY .and. inkey(0) == 32
DoLZCopy()
endcase
enddo
return 0
procedure DoLZCopy()
local cFile, cDst
local hSrc, hDst
local cSrcOFS, cDstOFS
local nRet
cFile = GetOpenFileName( , "*.??_", "Pick a file created by COMPRESS.EXE")
if cFile != nil
cDst = space(128)
nRet = GetExpandedName(cFile, @cDst)
// MessageBox( , nstr(nRet), "From GetExpandedName")
cDst = left(cDst, at(chr(0), cDst + chr(0)) - 1)
// MessageBox( , cDst, "From GetExpandedName")
cDst = GetSaveFileName( , cDst, "New name")
endif
if cFile != nil .and. cDst != nil
cSrcOFS = a2bin({0,0,0,space(4),space(128)}, OFS_A2BIN)
cDstOFS = a2bin({0,0,0,space(4),space(128)}, OFS_A2BIN)
hSrc = LZOpenFile(cFile, @cSrcOFS, OF_READ)
hDst = LZOpenFile(cDst, @cDstOFS, OF_CREATE)
nRet = LZCopy(hSrc, hDst)
LZClose(hSrc)
LZClose(hDst)
if nRet >= 0
MessageBox( , nstr(nRet), "Size of new file")
else
MessageBox( , nstr(nRet), "Error code from LZCopy")
endif
endif
return
// Get original file name (if COMPRESS /R was used), else cSrc
_DLL function GetExpandedName(cSrc AS STRING, cDst AS STRING) ;
AS INT Pascal:LZEXPAND.GetExpandedName
_DLL function LZOpenFile(cFile AS STRING, cOFS AS STRING, nFlags AS UINT) ;
AS INT Pascal:LZEXPAND.LZOpenFile
_DLL function LZCopy(hSrc AS INT, hDst AS INT) AS LONG Pascal:LZEXPAND.LZCopy
_DLL function LZClose(hFile AS INT) AS VOID Pascal:LZEXPAND.LZClose