Page 1 of 1

Posted: Wed Feb 26, 2003 8:50 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Hi all,

I know, the BOOL Type is supposed to hold True or False, but what type of VAriable is it exactly?
I mean, how much memory does it take? Can it be represented by BYTE, WORD or LONG?

If I get a BOOL as Result oaf an API Call, i always stor it in a LONG, but now, it is the other Way around:

I need to define a Structure with a lot of BOOL Variables, and PAss this Structure to a DLL.

So what Type is a BOOL exactly?

Thanks for any Help...

Timo

Posted: Wed Feb 26, 2003 9:15 pm
by BackupUser
Restored from previous forum. Originally posted by plouf.

This Depended on the languange most languanges uses a Byte
VisualBasic uses 2bytes (...)

Christos

Posted: Wed Feb 26, 2003 9:19 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

The Dll is written in C.

I'll try with a Byte, thanks...

Timo

Posted: Wed Feb 26, 2003 11:23 pm
by BackupUser
Restored from previous forum. Originally posted by VPureBasic.

Hi Freak,
Originally posted by freak

Hi all,

I know, the BOOL Type is supposed to hold True or False, but what type of VAriable is it exactly?
I mean, how much memory does it take? Can it be represented by BYTE, WORD or LONG?

If I get a BOOL as Result oaf an API Call, i always stor it in a LONG, but now, it is the other Way around:

I need to define a Structure with a lot of BOOL Variables, and PAss this Structure to a DLL.

So what Type is a BOOL exactly?

Thanks for any Help...

Timo
If my knowledge is good, BOOL is most of the time uses as WORD / SHORT
value... ( I know that the amiga includes uses BOOL as word and some Windows API )

Roger

Posted: Wed Feb 26, 2003 11:25 pm
by BackupUser
Restored from previous forum. Originally posted by Inner.

BOOL from my language is True / False or 0/1

Posted: Thu Feb 27, 2003 12:07 am
by BackupUser
Restored from previous forum. Originally posted by Kale.

VB's take on Booleans:
http://msdn.microsoft.com/library/defau ... oolean.asp

--Kale

In love with PureBasic! :)

Posted: Thu Feb 27, 2003 8:48 am
by BackupUser
Restored from previous forum. Originally posted by fred.

Just took a look in the Windows header (WinDef.h) and here is the def for a BOOL in C:

typedef int BOOL;

Ok, you guessed it, it's a normal 32 bits (long) value.

Fred - AlphaSND

Posted: Thu Feb 27, 2003 9:38 am
by BackupUser
Restored from previous forum. Originally posted by freak.

Ok, thanks for the Info, i think i got that part working now.

I've got another Question to all those C experts out there...

Code: Select all

typedef struct {
int  argc;              = Count of files to zip
LPSTR lpszZipFN;        = Archive file name
char **FNV;             = file names to zip up. Think of this an argv
} ZCL, _far *LPZCL;
I need to define that one in PureBasic, and fill it with the required Information.
I don't know, what this **FNV is exactly. There must be the Filenames stored in there somehow.

Thanks for any help...

Timo

Posted: Thu Feb 27, 2003 11:32 am
by BackupUser
Restored from previous forum. Originally posted by fred.

char *Text is a pointer to a string (like a regular string in PureBasic in fact)
char **Text is a pointer to a pointer, which means you can have an array of pointer of string.

In PB, it's still a 32 bits value (pointer) but to access the string it's like this:

PeekS(PeekL(Text))

instead of

PeekS(Text) for the first case

I hope it helps.

Posted: Fri Feb 28, 2003 1:28 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Hi again,

Sorry, but I can't get this thing to work! :cry:
The Program always quits at the last DLL call, without any Errormessage like Acess Violation or something like that.

All I want to do is pack one Exe File into one new Zip File, that's all.

If you want to try yourelve, get the DLL here:
ftp://ftp.info-zip.org/pub/infozip/WIN32/zip22dN-ms.zip

Here is my code including the (very little) information that was given with the DLL.
Can somebody please tell me if I made a mistake translating the Stuff here? (The Last DLL call doesn't work)

Thanks,

Timo

-----------------------------------------------------

Code: Select all

; int WINAPI DummyPassword(char *p, int n, const char *m, const char * name)
; {
; Return 1;
; }
Procedure Zip_password(p.l, n.l, m.l, name.l)
  ProcedureReturn 1
EndProcedure


; int WINAPI DummyPrint(char far *buf, unsigned long size)
; {
; Return (unsigned int) size;
; }
Procedure Zip_print(buf.l, size.l)
  ProcedureReturn size
EndProcedure

; char far * WINAPI DummyComment(char far *szBuf)
; {
; szBuf[0] = '\0';
; Return szBuf;
; }_
Procedure Zip_comment(szBuf.l)
  PokeB(szBuf, 0)
  ProcedureReturn szBuf
EndProcedure


; typedef struct {
; DLLPRNT *print;          = pointer to application's print function.
; DLLPASSWORD *password;   = pointer to application's function for processing
;                            passwords. Called from ttyio.c
; DLLCOMMENT *comment;     = pointer to application's function for processing
;                            comments.
; } ZIPUSERFUNCTIONS, far * LPZIPUSERFUNCTIONS;
Structure ZIPUSERFUNCTIONS
  print.l;          = pointer to application's print function.
  password.l;   = pointer to application's function for processing passwords. Called from ttyio.c
  comment.l;     = pointer to application's function for processing comments.
EndStructure


; typedef struct {
; BOOL fSuffix            = Currently not used by WiZ
; BOOL fEncrypt;          = encrypt file
; BOOL fSystem;           = include system and hidden files
; BOOL fVolume;           = Include volume label
; BOOL fExtra;            = Exclude extra attributes
; BOOL fNoDirEntries;     = Do not add directory entries
; BOOL fDate;             = Exclude files earlier than specified date
; BOOL fVerbose;          = Mention oddities in zip file structure
; BOOL fQuiet;            = Quiet operation
; BOOL fCRLF_LF;          = Translate CR/LF to LF
; BOOL fLF_CRLF;          = Translate LF to CR/LF
; BOOL fJunkDir;          = Junk directory names
; BOOL fRecurse;          = Recurse into subdirectories
; BOOL fGrow;             = Allow appending to a zip file
; BOOL fForce;            = Make entries using DOS names (k for Katz)
; BOOL fMove;             = Delete files added or updated in zip file
; BOOL fDeleteEntries;    = Delete files from zip file
; BOOL fUpdate;           = Update zip file--overwrite only if newer
; BOOL fFreshen;          = Freshen zip file--overwrite only
; BOOL fJunkSFX;          = Junk SFX prefix
; BOOL fLatestTime;       = Set zip file time to time of latest file in it
; BOOL fComment;          = Put comment in zip file
; BOOL fOffsets;          = Update archive offsets for SFX files
; BOOL fPrivilege;        = Save privileges
; BOOL fEncryption        = Read only option, true If encryption supported,
;                           false otherwise.
; int fRepair;            = 1 => fix archive, 2 => try harder to fix
; char fLevel;            = Compression level (0 - 9)
; char Date[7];           = Date to include files after
; char szRootDir[256];    = Directory to use as base for zipping
; } ZPOPT, _far *LPZPOPT
Structure ZPOPT
  fSuffix.l;           = Currently not used by WiZ
  fEncrypt.l;          = encrypt file
  fSystem.l;           = include system and hidden files
  fVolume.l;           = Include volume label
  fExtra.l;            = Exclude extra attributes
  fNoDirEntries.l;     = Do not add directory entries
  fDate.l;             = Exclude files earlier than specified date
  fVerbose.l;          = Mention oddities in zip file structure
  fQuiet.l;            = Quiet operation
  fCRLF_LF.l;          = Translate CR/LF to LF
  fLF_CRLF.l;          = Translate LF to CR/LF
  fJunkDir.l;          = Junk directory names
  fRecurse.l;          = Recurse into subdirectories
  fGrow.l;             = Allow appending to a zip file
  fForce.l;            = Make entries using DOS names (k for Katz)
  fMove.l;             = Delete files added or updated in zip file
  fDeleteEntries.l;    = Delete files from zip file
  fUpdate.l;           = Update zip file--overwrite only If newer
  fFreshen.l;          = Freshen zip file--overwrite only
  fJunkSFX.l;          = Junk SFX prefix
  fLatestTime.l;       = Set zip file time to time of latest file in it
  fComment.l;          = Put comment in zip file
  fOffsets.l;          = Update archive offsets for SFX files
  fPrivilege.l;        = Save privileges
  fEncryption.l;       = Read only option, true If encryption supported, false otherwise.
  
  fRepair.l;           = 1 => fix archive, 2 => try harder to fix
  fLevel.b;            = Compression level (0 - 9)
  Date.b[9];           = Date to include files after
  szRootDir.b[256];    = Directory to use as base for zipping
EndStructure

; typedef struct {
; int  argc;              = Count of files to zip
; LPSTR lpszZipFN;        = Archive file name
; char **FNV;             = file names to zip up. Think of this an argv
; } ZCL, _far *LPZCL;
Structure ZCL
  argc.l;              = Count of files to zip
  lpszZipFN.l;         = Archive file name
  FNV.l;               = file names to zip up. Think of this an argv
EndStructure

#Zip = 1
Zip.s = "Zip32.dll"          ; DLL Name
Source.s = "TestProg.exe"    ; Programm to Zip
SourceP.s = "C:\Temp\"       ; Path of Program
Dest.s = "C:\Temp\Test.zip"  ; Zip File

If OpenLibrary(#Zip, Zip)=0
  MessageRequester("","Lib",0)
  End
EndIf

ZpUSER.ZIPUSERFUNCTIONS
ZpUSER\print = @Zip_print()
ZpUSER\password = @Zip_password()
ZpUSER\comment = @Zip_comment()

;int WINAPI ZpInit(ZIPUSERFUNCTIONS far * lpZipUserFunc); What does this far stuff mean?
Debug CallFunction(#Zip, "ZpInit", @ZpUSER)  

ZpOpt.ZPOPT
ZpOpt\fNoDirEntries = #TRUE
ZpOpt\fLatestTime = #TRUE
ZpOpt\fLevel =  0
ZpOpt\Date[0] = 0
PokeS(@ZpOpt\szRootDir[0], SourceP)

;BOOL WINAPI ZpSetOptions(ZPOPT)
Debug CallFunction(#Zip, "ZpSetOptions", @ZpOpt)  ;<- I'm not compleetly sure about this part
                                                  ; Maybe there is some fault here, and that 
                                                  ; causes a later crash?
Dim FileNames.s(5)
FileNames(0) = Source

Zcl.ZCL
Zcl\argc = 1
Zcl\lpszZipFN = @Dest
Zcl\FNV = @FileNames(0)

;The main entry point is ZpArchive(ZCL C)
Debug CallFunction(#Zip, "ZpArchive", @Zcl)  ;<- here it crashes, or exits without any errormessage

MessageRequester("","done",0)

CloseLibrary(#Zip)

Posted: Fri Feb 28, 2003 3:22 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Zcl\FNV = @FileNames(0)

should be (IHMO):

Zcl\FNV = @FileNames()

Because the first one returns the address of the string at the position 0. The second returns the arrays address
which is what you want.

Fred - AlphaSND

Posted: Fri Feb 28, 2003 4:49 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

I allready tried that, but I doesn't work. I also check if it was a CDECL Dll, but no success :cry:
I fact, I tried a lot of things now, but I only get crashes all the time.

I think I'm going to call an exernal Zip tool to do what I want, now (not a very good solution)
If anyone ever succeeds in using a DLL to handle Zip files, please let me know...

Anyway, thanks for trying to help me...

Timo