Jump to content

Creating a Dll structure


Rizzet
 Share

Recommended Posts

Hi, ive tried creating this dll structure to CDBFAPI.DLL but failed,

Could you help me?

struct DBF {
    [...]
    char    *filename;          // the name of DBF-file
    char    *filename_memo;     // the name of a memo-file (DBT or FPT)
        char    *filename_hdr;    // the name of header-file (HDR)
    
        struct  Header hdr;         // the first 32 bytes of header
        struct  Field fld[2048];    // the description of fields
        char      als[2048][32];    // headers of fields
    
        int     Fieldorder[2048];   // the order of  fields
    
        struct  Options opt;        // options
    
        unsigned short num_fld;     // the number of fields
        [...]   
        int memo_field;         // the current memo-field or -1, 
                        // if a memo-fields is not present
        [...]   
        char    *record_block;      // pointer to area of reading/writing
        char    *str;           // pointer to area of the return of lines
        char    *memo_block;        // pointer to memo-fields
        [...]
        char    *copy_of_record;    // copy of record
        [...]
};
Link to comment
Share on other sites

It's not possible do translate that struct just by looking at it (you need to now how the other structs looks like), but here's some tricks that will be needed:

- A struct in a struct means you insert the other struct in the first, so if the declaration say:

Struct structa{
int test;
int test2;
};

Struct structb{
char x;
structa info;
int age;
};

The AutoIt equal is:

$structb=DllStructCreate("char x;int test;int test2;int age;")

- You cannot declare 2D arrays i a AutoIt DllStruct, however array[32][8] is the same as array[8*32]

- char *string means a pointer to a char array that holds the string, therefore to store a string when the declaration says char *string you do it like this:

$struct=DllStructCreate("ptr ptrtostring;"); Create the struct that has the pointer

$string=DllStructCreate("char name[255];"); Creates the string that actually holds the string
DllStructSetData($string,"name","Andreas!"); Save Andreas! in the string

DllStructSetData($struct,"ptrtostring",DllStructGetPtr($string)); Save the pointer to the string in the first struct

Good luck :P

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...