AutoHotkey Community

It is currently May 27th, 2012, 6:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: January 15th, 2006, 2:10 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
I want to use a dll for compressing files to zip format. I found zip32.dll here.
As far as I understand it, it seems to need a structure with strings (and others) for DllCall.
Is it possible to use this DLL with strings structure in AutoHotkey?
Thanks
Code:
(From WinDll.txt included in the download:)
BOOL WINAPI ZpSetOptions(ZPOPT)
typedef struct {
LPSTR Date;             /* Date to include after */
LPSTR szRootDir;        /* Directory to use as base for zipping */
LPSTR szTempDir;        /* Temporary directory used during zipping */
BOOL fTemp;             /* Use temporary directory '-b' during zipping */
BOOL fSuffix;           /* include suffixes (not implemented in WiZ) */
BOOL fEncrypt;          /* encrypt files */
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 fExcludeDate;      /* Exclude files earlier than specified date */
BOOL fIncludeDate;      /* Include only 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 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;        /* Use privileges (WIN32 only) */
BOOL fEncryption;       /* TRUE if encryption supported, else FALSE.
                           this is a read-only flag */
int  fRecurse;          /* Recurse into subdirectories. 1 => -r, 2 => -R */
int  fRepair;           /* Repair archive. 1 => -F, 2 => -FF */
char fLevel;            /* Compression level (0 - 9) */
} ZPOPT, _far *LPZPOPT;


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 15th, 2006, 7:04 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
Peter wrote:
structure with strings... Is it possible to use this DLL with strings structure in AutoHotkey?

typedef struct {
LPSTR Date;
...
}


Yes.

LPSTR is a null-terminated string, and is defined as a pointer to a character (uint1) array. For example:

Code:
VarSetCapacity( struct, struct_size, 0 )

date = Sunday, January 15, 2006

EncodeInteger( &date, 4, &struct, 0 )
etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 15th, 2006, 9:28 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
Thank you. :)
I hope I can get it working now.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 9th, 2006, 1:48 pm 
Offline

Joined: May 27th, 2005, 4:14 pm
Posts: 35
Hi Peter, did you get it working?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2006, 9:13 am 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
Regarding my question about ZpSetOptions, it seems to work so far, but not the zip function itselfs. Because, as far as I understand you have to be able to use Callback for the ZpArchive function of the dll. At that point I gave up. And AFAIK it's not possible in AHK.
So, maybe it's possible to use in AHK, but it goes beyond my knowledge.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2006, 9:25 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
No it is not possible to use callbacks in AHK.
That is why I urge so hard for & extension to return function address.

Acctually it is possible to do so, but it requires nasty hack and good ASM knowledge. Chris rised priority to & wish so lets hope it will come soon.

Btw, peter, you might be able to find dll that will be able to compress without callback function. I am sure you ca.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 3:03 am 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
Hi, I have a similar problem. I want to call:
Code:
void __stdcall SetDefaultParams(ParamStruct* dps);

typedef struct {
    int size;
    DWORD VersionLow;
    DWORD VersionHigh;
    char FileName[MAX_PATH];
} ParamStruct;


But I can't get it to work. Here is what I got:
Code:
ParamStruct_FileName=C:\test.txt
VarSetCapacity(ParamStruct, 16, 0)
NumPut(16, ParamStruct, 0, "int")
NumPut(2 , ParamStruct, 4, "uint")
NumPut(0 , ParamStruct, 8, "uint")
;NumPut(0 , ParamStruct, 12, "uint")
EncodeInteger(&ParamStruct + 12, &ParamStruct_FileName)
DllCall("dllfile.dll\SetDefaultParams" ,"uint", &ParamStruct)

EncodeInteger(Destination, Value)
{
    DllCall("ntdll\RtlFillMemoryUlong", "Uint", Destination, "Uint", 4, "Uint", Value)
}

Perhaps it is the "char[MAX_PATH]" that makes trouble?

_________________
http://www.familie-plentz.de


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 6:15 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Right, a char array in a struct is different from having a pointer to a string. The char array occupies space inside the struct equal to the size of the array. So, your struct will need to be much bigger than 16 bytes... maybe 272 bytes?

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 7:59 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Should be something like:

Code:
File := "C:\test.txt"
StructLen := 12 + StrLen( File ) + 1
VarSetCapacity( ParamStruct, StructLen, 0 )
NumPut( StructLen, ParamStruct, 0, "Int"  )
NumPut(  2, ParamStruct, 4, "UInt" )
StrPut( File, &ParamStruct+12 )

;DllCall("dllfile.dll\SetDefaultParams" ,"uint", &ParamStruct)

_=_______________________________________________________________________

; A function pair to read/write strings from/to memory address.

StrPut( Str, @ ) {
Return DllCall( "RtlMoveMemory", UInt,@, UInt,&Str, UInt,StrLen(Str) )
}

StrGet( @ ) {
Return DllCall( "MulDiv", int,@, int,1, int,1, "Str" )
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2010, 8:35 am 
Offline

Joined: July 26th, 2006, 11:25 am
Posts: 19
Thanks for your help!
SKAN, your example works like a charm.

_________________
http://www.familie-plentz.de


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], Exabot [Bot], JSLover and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group