 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Sun Jan 15, 2006 1:10 pm Post subject: DllCall and structure with strings |
|
|
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;
|
|
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 610
|
Posted: Sun Jan 15, 2006 6:04 pm Post subject: Re: DllCall and structure with strings |
|
|
| 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.
|
|
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Sun Jan 15, 2006 8:28 pm Post subject: |
|
|
Thank you.
I hope I can get it working now. |
|
| Back to top |
|
 |
Venia Legendi
Joined: 27 May 2005 Posts: 35
|
Posted: Mon Oct 09, 2006 12:48 pm Post subject: |
|
|
| Hi Peter, did you get it working? |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 448
|
Posted: Wed Oct 11, 2006 8:13 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Wed Oct 11, 2006 8:25 am Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
 |
SamuelPlentz
Joined: 26 Jul 2006 Posts: 19
|
Posted: Sun Apr 25, 2010 2:03 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Sun Apr 25, 2010 5:15 am Post subject: |
|
|
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! |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Apr 25, 2010 6:59 am Post subject: |
|
|
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" )
} |
|
|
| Back to top |
|
 |
SamuelPlentz
Joined: 26 Jul 2006 Posts: 19
|
Posted: Sun Apr 25, 2010 7:35 am Post subject: |
|
|
Thanks for your help!
SKAN, your example works like a charm. _________________ http://www.familie-plentz.de |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|