Page 1 of 1
Need help on how can I build an extension for my external dll and call it on my livecode builder
Posted: Tue Mar 05, 2019 6:27 am
by jpags.me
I have a dll file with a function to multiply 2 numbers just for a proof of concept. How do I do it?
I have this strip of code I wrote but it is giving some errors.
Code: Select all
library test_new_lcb
use com.livecode.foreign
private __safe foreign handler _Hello(in pName as string) returns string binds to "new_dll>Hello"
public handler _Hello() returns String
variable name as pName
_Hello(name)
answer(name)
end handler
end library
Is there something wrong with this code? Please help with this. I am stuck on this for 2 days now.
Re: Need help on how can I build an extension for my external dll and call it on my livecode builder
Posted: Wed Mar 06, 2019 1:19 pm
by sphere
i wish i could help you.
I did all the lessons on the livecode builder and that worked, but i would really not know how to uase a dll form any api or whatever and connect it with LC builder.
Maybe you can look at some other examples here on the forum, or look for trevore devore on github. He did some things also connecting to certain dll's, maybe it helps you.
Re: Need help on how can I build an extension for my external dll and call it on my livecode builder
Posted: Wed Mar 06, 2019 2:58 pm
by trevordevore
@jpags.me - `string` is not a valid variable type for foreign handlers. You can use ZStringNative, ZStringUTF8, or ZStringUTF16. This file lists them and has descriptions:
https://github.com/livecode/livecode/bl ... -naming.md
A reference to ZString should appear in the LCB guide but I don't see it listed:
https://github.com/livecode/livecode/bl ... n-handlers
Here are some files that bind to DLLs on Windows that should provide some guidance.
Take a look at my WinSparkle repo on GitHub:
https://github.com/trevordevore/lc-wins ... parkle.lcb
These two are from the LiveCode repo:
Timezone.lcb:
https://github.com/livecode/livecode/bl ... mezone.lcb
ini.lcb:
https://github.com/livecode/livecode/bl ... ni/ini.lcb
Re: Need help on how can I build an extension for my external dll and call it on my livecode builder
Posted: Thu Mar 07, 2019 4:17 am
by jpags.me
Thank you guys! I will take a look at these and understand it all.