cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
menos16
Level 4

calling dll sqlite

Hello people, I'm trying to desing BasicMSI with an Installscript custom action for create an easy DDBB with sqlite3.dll

I'm following some examples in this forum, but the call to the function allways FAIL, and I don't know why.

prototype cdecl INT sqlite3.sqlite3_open(STRING,POINTER);
#include "Ifx.h"
export prototype FINAL(HWND);
function FINAL(hMSI)

POINTER nResult;
STRING ERROR1,ERROR;
INT bResult;

begin
bResult = UseDLL ( "sqlite3.dll" ); // (load is OK)
bResult = sqlite3_open("ABCDE",nResult);
UnUseDLL("sqlite3.dll");
end;

I'm not a programmer and this script is the first call that I desing to a C++ dll ... I'm not sure what type of parameter is "sqlite3 **ppDb" and how to retrieve it.

Can anyone give a clue? what I'm doing wrong?

thanks for your time.

(sorry for the duplicate post, but no answers in the original thread, if there is more lucky here....)
Labels (1)
0 Kudos
(2) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

Generally this kind of argument (a pointer to a pointer) is used for returning a pointer to the caller. You might try declaring the argument as BYREF POINTER instead of just POINTER, or passing &nResult instead of nResult. Programming without learning how is going to be difficult, though, and cross-language interfacing is not a very easy topic to start with. 🙂
0 Kudos
menos16
Level 4

yes the change to BYREF POINTER was the answer. A lot of thanks


prototype cdecl INT sqlite3.sqlite3_open(STRING,BYREF POINTER);
prototype cdecl INT sqlite3.sqlite3_exec(POINTER,STRING);
prototype cdecl INT sqlite3.sqlite3_close(POINTER);


POINTER ppDb;
INT nResult,BufferSize;
STRING string1,string2;

begin
UseDLL("sqlite3.dll");

nResult = sqlite3_open(CommonAppDataFolder^"Digital.sqlite",ppDb);

BufferSize = 500;
nResult = MsiGetProperty(ISMSI_HANDLE,"PROPERTY1",string1,BufferSize);BufferSize = 500;
nResult = MsiGetProperty ...............
...
...
...

Command = "CREATE TABLE abc (ID Text PRIMARY KEY ......)";
nResult = sqlite3_exec(ppDb,Command);

Command = "INSERT INTO abc (colum1,colum2) VALUES ('"+string1+"','"+string2 +"')";
nResult = sqlite3_exec(ppDb,Command);

nResult = sqlite3_close(ppDb);
UnUseDLL("sqlite3.dll");
end;


was not as complicated 😉
0 Kudos