Archive: A question regarding how to call a function


A question regarding how to call a function
Suppose a function is defined in C++ as void foo(int& x). Assume foo is defined in fooLib.dll. I tried to call System::call "fooLib::foo(i.r0) in nsis. But I couldn't get value of x assigned within the function foo. How to call foo correctly in nsis? Thanks.


By adding a period before r0 you're telling the system plugin that it's an output variable (so the return value gets put there). Try System::call "fooLib::foo(i r0)


Originally posted by MSG
By adding a period before r0 you're telling the system plugin that it's an output variable (so the return value gets put there). Try System::call "fooLib::foo(i r0)
Thanks for your reply. The following is how I call a function defined in myLib.dll from NSIS script.

// C++ code
BOOL __stdcall test(BOOL& btest)
{
TCHAR s[12];
_tcscpy(s, _T("1"));
_stscanf(s, _T("%d"), &bTest);

return TRUE;
}

// NSIS script
System::call "myLib::test(i r0) i.r1"

But it looks like test never returns. Is there anything wrong? Thanks.

I'm not a programmer. But... did you fix your system::call syntax?


Originally posted by MSG
I'm not a programmer. But... did you fix your system::call syntax?
This is how I did, System::call "myLib::test(i r0) i.r1". Basically, r0 is a output parameter I expect to get the result in NSIS script from dll. It did call function test but somehow the function test never returns. I am not sure what went wrong. Do you have any idea? Thanks a lot.

Errr oops, missed that line in your post. Dunno, let's hear an actual programmer. Someone take over plz?


I figured out. It should be System::call "myLib::test(*i.r0) i.r1". Thanks.