Write the NSIS plug-in using Rust


use std::os::raw::c_double;

pub unsafe extern fn hello(value1: c_double, value2: c_double) -> c_double {
  return value1 + value2

nsis script

// It has not been performed correctly using this approach
my_dll::hello 100 200
pop $0
pop $1
pop $2
MessageBox MB_OK "returns:$0"      // result is 100,   But I expected 300
MessageBox MB_OK "returns:$1"      // result is 200,   But I expected null value
MessageBox MB_OK "returns:$2"      // result is null value

nsis script

// This is the right way to use it
StrCpy $0 100
StrCpy $1 2
StrCpy $2 ""
System::Call "C:\Users\dddddd\AppData\Local\electron-builder\Cache\nsis\nsis-\Plugins\x86-unicode\test_dll::hello(i, i) i(r0, r1).r2"
MessageBox MB_OK "returns:$2"              //  result is 102,  correctly 

But I want to use the first NSIS script, Help me !

Help me

What calling convention does NSIS expect in the first place? It seems like a mismatch between the calling convention NSIS expects and what the default C calling convention is on your platform. By the way for which platform are you compiling (os and cpu arch)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.