JohnChen
22nd April 2011 20:28 UTC
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.
MSG
22nd April 2011 22:56 UTC
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)
JohnChen
25th April 2011 19:00 UTC
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.
MSG
25th April 2011 19:11 UTC
I'm not a programmer. But... did you fix your system::call syntax?
JohnChen
25th April 2011 19:22 UTC
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.
MSG
25th April 2011 20:41 UTC
Errr oops, missed that line in your post. Dunno, let's hear an actual programmer. Someone take over plz?
JohnChen
25th April 2011 22:27 UTC
I figured out. It should be System::call "myLib::test(*i.r0) i.r1". Thanks.