Jump to content

Autoit And Cdbase


 Share

Recommended Posts

I'd like to user cdbase.dll, but I am doing something wrong and have no clue what goes wrong.

Here's my souce code (comments are C source code from CDBase Help):

;DBHANDLE dbh;
;CDB_TABLE table;
;CDB_COLUMN columns[2];

;dbh = cdbCreateDatabase("myDatabase.cdb");   // Create the database
;cdbStartTransaction(CDB_WRITING,dbh);         // Start a transaction
;columns[0].datatype = CDB_DT_SHORT;             // Define the columns
;columns[0].size = 1;
;columns[0].indexed = FALSE;
;columns[1].datatype = CDB_DT_CHAR;
;columns[1].size = 64;
;columns[1].indexed = TRUE;
;table.szName = "MYTABLE";                     // Define the table
;table.columns = columns;
;table.nColumns = 2;
;cdbAddTable(&table,dbh);                       // Add the table to the database
;cdbEndTransaction(TRUE,dbh);                   // End the transaction and commit changes
;cdbCloseDatabase(dbh);                       // Close the database

$lib = DllOpen("resources\cdbase.dll")
If $lib = -1 Then
    MsgBox(16, "DLL Error", "Cannot open 'cdbase.dll'")
    Exit(1)
EndIf

$dbh = DllCall($lib, "ptr", "cdbCreateDatabase", "str", "Books.cdb")
TestError(@error, "cdbCreateDatabase")

DllCall($lib, "none", "cdbStartTransaction", "int", 0xc0000000, "ptr", $dbh)
TestError(@error, "cdbStartTransaction")

Func TestError($err, $fce)
    Local $str
    If $err = 0 Then
        Return
    EndIf
    
    Switch $err
    Case 1
        $str = "Unable to use DLL"
    Case 2
        $str = "Unknown return type"
    Case 3
        $str = "Function not fount in the DLL file"
    EndSwitch
    MsgBox(16, "DLL Error", $str&@CRLF&"at "&$fce)
EndFunc

I got 'Unable to use DLL file at cdbCreateDatabase' message. Why? What am I doing wrong?

Thx for your help.

BTW: If you want to try this database, it's attached.

[right]Software is like sex - it's better when it's free. (Linus Torvalds)[/right]

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...