MqxM
Deno3y 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()
Medium
Learn how to call C functions from Windows DLL in Deno using arbitrary buffers
Was this page helpful?