DenoDDeno
Powered by
MqxM
Denoโ€ข3y agoโ€ข
116 replies
Mqx

Pass string from TS to dll and return the passed string. (Like echo)

Hey I am currently trying to understand the communication between a dll and my TS program. Currently I am simply trying to pass a string to the dll and have the dll give me the string back. Similar to an echo. I have been trying to follow this guide for this: https://medium.com/deno-the-complete-reference/calling-c-functions-from-windows-dll-in-deno-part-2-buffers-131226acd3d2 only somehow I can't pass the buffer in my TS program. Can someone give me a simple example of how to pass a string from TS to dll and from dll to TS?

const dll = Deno.dlopen('./test.dll', {
    'echo': {
        parameters: ['pointer'],
        result: 'pointer'
    }
})

const buffer = new TextEncoder().encode('Hello World!')

console.log('echo:', dll.symbols.echo(buffer));

dll.close()
const dll = Deno.dlopen('./test.dll', {
    'echo': {
        parameters: ['pointer'],
        result: 'pointer'
    }
})

const buffer = new TextEncoder().encode('Hello World!')

console.log('echo:', dll.symbols.echo(buffer));

dll.close()
Medium
Calling C functions from Windows DLL in Denoโ€Šโ€”โ€ŠPart 2 Buffers
Learn how to call C functions from Windows DLL in Deno using arbitrary buffers
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Next page

Similar Threads

Pass string to struct FFI
HiroHHiro / help
4y ago
KV: What to return from here?
Timo MartinsonTTimo Martinson / help
3y ago
GetIP + Ctx from middleware to a route not passed
foobarFfoobar / help
3y ago
Trying to pass parameters to runtime from rust
andres-movinglakeAandres-movinglake / help
3y ago