Page 1 of 1

DLL32 problem

Posted: Fri Jan 25, 2008 4:21 am
by Roger Seiler
Antonio,

I get an "error Base/1003 variable does not exst LPLONG" when calling a dll function via DLL32. I notice that in the fwcmd.chm docs, in the explanation for DLL32 it does not list LPLONG as a data type, though it does list LPSTR. Insofar as this seems to be a common C datatype, can LPLONG be added as a valid data type used in a C function that is included in a DLL?

Specifically, I'm getting this error with the Protection PLUS function calls to its 32 bits DLL when using the command DLL32. For example:

DLL32 FUNCTION pp_checksum(filename AS LPSTR, checksum AS LPLONG) AS LONG PASCAL LIB "keylib32.dll"

- Roger

Posted: Fri Jan 25, 2008 4:58 am
by Roger Seiler
I tried using PTR in the DLL32 command instead of LPLONG and that didn't work either - didn't get an error message, but the test app acted like it was stuck in a never-ending loop.

- Roger

Posted: Fri Jan 25, 2008 10:31 am
by Antonio Linares
Roger,

Please use a C function instead of the DLL FUNCTION command, just to be sure its right.

You may use #pragma BEGINDUMP ... #pragma ENDDUMP

Posted: Fri Jan 25, 2008 12:36 pm
by Roger Seiler
Antonio,

Do you mean that I can insert a C function into an FWH prg by:

1. preceding it with the line #pragma BEGINDUMP

2. then write in a line with the C function, and then

3. follow it with the line #pragma ENDDUMP, and then

4. continue with my FWH code?

Or does the C code have to be in a separate prg?

And if #pragma enables mixing C code with FWH code, are the variables used in the C function directly visible to the rest of the FWH code?

(Obviously, I'm not much of a C programmer or I'd already know this. I've never used the #pragma capability before, so I'm learning something new here.)

Thanks!

- Roger

Posted: Fri Jan 25, 2008 6:27 pm
by Antonio Linares
Roger,

Yes, you can include a C function in your PRG as you have described it.

Please make a search for BEGINDUMP in these forums and you will find lots of samples :-)

PRAGMA

Posted: Sat Jan 26, 2008 5:29 pm
by TimStone
Antonio,

I've been looking at the samples and it would appear your suggestion involves placing C code directly into FWH.

Our need is to call a C function in a DLL. The problem we encounter is the Data Type LPLONG is not supported in FWH.

So, the following call:

nReturn := pp_lfopen( 'test.lf', LFOPEN_NOCACHE, LF_FILE, 'password', nLFhandle )

With the following DLL:

DLL32 Function pp_lfopen( filename As LPSTR, lfflags As LONG, lftype As LONG, password As LPSTR, handle As LPLONG) As LONG PASCAL LIB "Keylib32.dll"

Will return the error Undefined LPLONG

Can you give a quick sample of how to access the function in the DLL ... and then we can rewrite all the functions in the same manner and make the result to other FWH users who wish to access the current SoftwareKey libraries.

Thank you ...

Re: PRAGMA

Posted: Sat Jan 26, 2008 6:12 pm
by Enrico Maria Giordano
Try:

Code: Select all

   nReturn := pp_lfopen( 'test.lf', LFOPEN_NOCACHE, LF_FILE, 'password', @nLFhandle )

Code: Select all

DLL32 Function pp_lfopen( filename As LPSTR, lfflags As LONG, lftype As LONG, password As LPSTR, @handle As PTR) As LONG PASCAL LIB "Keylib32.dll"
EMG

Thank you

Posted: Sat Jan 26, 2008 7:19 pm
by TimStone
We tried PTR but the culprit was the missin @ for nHandle. Thank you. I'll move ahead now ... it is much appreciated.

Posted: Mon Jan 28, 2008 8:08 am
by hua
I use only a few of the functions provided by SoftwareKey. This is what I have so far:

Code: Select all

DLL32 FUNCTION pp_eztrial1(file AS LPSTR, password AS LPSTR,@errcode AS LONG,@hnd AS LONG) ;
    AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_errorstr(errorcode AS LONG, @buffer AS LPSTR) ;
    AS VOID PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_lfclose(hnd AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_bitclear(bit_field AS LONG, bit_number AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_bittest(bit_field AS LONG, bit_number AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_bitset(bit_field AS LONG, bit_number AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_getvarnum(hnd AS LONG, varno AS LONG, @value AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_setvarnum(hnd AS LONG, varno AS LONG, value AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_getvarchar(hnd AS LONG, varno AS LONG, @buffer AS LPSTR) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_lfopen(filename AS LPSTR, flags AS LONG, lfType AS LONG, password AS LPSTR, @lfhnd AS LONG) ;
    AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_lfalias(lfhnd AS LONG, filename AS LPSTR, flags AS LONG, lfType AS LONG, password AS LPSTR, @lfNewest AS LONG) ;
    AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_libtest(testnum AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_redir(drive AS LPSTR) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_compno(type AS LONG, filename AS LPSTR, hdd AS LPSTR) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_copycheckth(hnd AS LONG, flags AS LONG, compno AS LONG, b AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_semopen(hnd AS LONG, sem_type AS LONG, path AS LPSTR, prefix AS LPSTR, @shnd AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_semclose(shnd AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_semcount(hnd AS LONG, sem_type AS LONG, path AS LPSTR, prefix AS LPSTR, @kount AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_upddate(hnd AS LONG, flags AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_expired(hnd AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_countinc(hnd AS LONG, var_no AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_setvarchar(hnd AS LONG, varno AS LONG, string AS LPSTR) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_valdate(hnd AS LONG) AS LONG PASCAL LIB "keylib32.dll"

DLL32 FUNCTION pp_getvardate(hnd AS LONG, var_no AS LONG, @month_hours AS LONG, @day_minutes AS LONG, @year_secs AS LONG) AS LONG PASCAL LIB "keylib32.dll"