Skip to content
⌘ NSIS Forum Archive

System plugin (call C static library function)

7 posts

jeusdi#

System plugin (call C static library function)

Hello forum,

I've developed a static C library: NSISWS.a.

NSISWS.h->
extern unsigned char* activateLicence(char* licence_type_code, char* customer_code);
NSISWS.c->

unsigned char* activateLicence(char* licence_type_code, char* customer_code)
{
unsigned char* result;
result = "fdfdfdfdfdfdfdf...";
return result;
}
I've copied NSISWS.a file on the same directory of my NSIS script. In order to call this function I use System plugin as follow:


System::Call "NSISWS::activateLicence("bl", "bl") c .r0
DetailPrint "Licence: $0"
The result is:


Can you help me please?
What Am I doing wrong?
I will appreciate your help a lot.
Anders#
") c .r0" and c would be??? you can't just make up types, you must read the system plugin readme

try System::Call "NSISWS::activateLicence(t "bl", t "bl")t.r0

not sure if returning a string like that will work, normally your function would look like:
void MyFunc(char*a,char*b,char*output)
{
lstrcpy(output,"hello");//must be < 1024 chars
}
and System::Call "dll::MyFunc(t "bl", t "bl",t.r0)

also remember that the function needs to be stdcall unless you pass ?c
jeusdi#
Hello Anders. Thanks for your response. I've modified function signature as:


unsigned int activateLicence(const char* licence_type_code, const char* customer_code, char* licence_filename);
And I call it as:

	System::Call "NSISWS.a::activateLicence(t "bla bla"., t "ble ble"., t.r1) t .r0
DetailPrint "Licence: $0"
I think that the method is not called, because this function creates a file and it is not created.

Can you help me, plase?
Thanks in advance.
Anders#
the function returns int, so why are the t??

also remember that the function needs to be stdcall unless you pass ?c
Joel#
Maybe you should try to make it as a plugin and use the function "setuservariable" to write things to the nsis stack.