Archive: System::Call dll is not working


System::Call dll is not working
  I wrote a DLL file. And I want to call during some installation process.

But it doesn't work. I searched and read some article about that, but I couldn't get it work.

I made my DLL file by Visual Studio 6. There are 1 public class and 1 function. A class has 1 public methods and 1 private method.

this is my nsi file.

Name "dllTest2"
OutFile "dllTest2.exe"
ShowInstDetails show

Section
SetPluginUnload alwaysoff
SetOutPath "$TEMP\ttt"
File MyDll.dll
System::Call "MyDll::ttt()i .r8"
System::Call 'MyDll::test(i "1", i "2") i .r1'
DetailPrint "After Calling: $1"
DetailPrint "After Calling: $8"
SetPluginUnload manual
SectionEnd


nsi file and dll file are placed in same folder.

The compile is ok, but the message is always "error".

After run the exe file, mydll.dll is in $TEMP\ttt folder. but I think dll call is not happened.

I need your help. How do I call mydll? Should I do anything else to call dll function?


Try extracting your dll to $PLUGINSDIR instead of $TEMP\ttt. system.dll will be in $PLUGINSDIR and expects your plugin to be there also.


Originally posted by dienjd
Try extracting your dll to $PLUGINSDIR instead of $TEMP\ttt. system.dll will be in $PLUGINSDIR and expects your plugin to be there also.
I fixed my nsi file as you've suggested and some line added like this.

DetailPrint "After Calling: $PLUGINSDIR"

$PLUGINSDIR is changed when I execute exe file. But when I go that folder, there is not my dll file. There's System.dll file only. What's wrong? I have no idea.

What should I do?

Hi inim, you are almost close to your task...try this:

Name "dllTest2"

>OutFile "dllTest2.exe"
>ShowInstDetails show

Section
SetPluginUnload alwaysoff
SetOutPath "$TEMP\ttt"
>!addplugindir "./" ; if you plugin is the same dir as you .nsi
System
::Call "MyDll::ttt(v) i .r8" ;note changes
System::Call 'MyDll::test(i 1, i 2) i .r1' ;note changes
DetailPrint "After Calling: $1"
>DetailPrint "After Calling: $8"
>SetPluginUnload manual
SectionEnd
>

Originally posted by Joel
Hi inim, you are almost close to your task...try this:

Name "dllTest2"

>OutFile "dllTest2.exe"
>ShowInstDetails show

Section
SetPluginUnload alwaysoff
SetOutPath "$TEMP\ttt"
>!addplugindir "./" ; if you plugin is the same dir as you .nsi
System
::Call "MyDll::ttt(v) i .r8" ;note changes
System
::Call 'MyDll::test(i 1, i 2) i .r1' ;note changes
DetailPrint "After Calling: $1"
>DetailPrint "After Calling: $8"
>SetPluginUnload manual
SectionEnd
>
I fixed the code, but it didn't work. I wonder it works though there's no path to my dll file. Does "!addplugindir" make it possible? Anyway, there's no files where the outPath that I specified. However when I add a line "File mydll.dll" there is my dll.

I have a question. Is it possible that my dll file is not correct? It was just made by app. wizard of VS 6.0. But I tested it by calling from console program.

I downloaded the tutorial and read some articles, but I can't make my app. work as I wished.

Anyway I really appreciate your suggestion.

Is it possible that my dll file is not correct? It was just made by app. wizard of VS 6.0. But I tested it by calling from console program.
Can we see your compiled DLL? Something is not right.
!addplugindir will scan the given directory for plugins, so you can call them as you want.

You could just convert your plugin into an NSIS plugin and call it like that. You wouldn't need to use the System plugin then and if you're not using it elsewhere in your script you'll save some space (not that it matters too much anyway).

Theres a plugin example called ExDll included with the latest NSIS bundle (or source code bundle).

Stu


Originally posted by Joel
Can we see your compiled DLL? Something is not right.
This code is mydll.h. And I attached MyDll.dll.

#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif

class MYDLL_API CMyDll {
public:
CMyDll(void);
int test(int, int);
};

extern MYDLL_API int nMyDll;

MYDLL_API int ttt(void);


Anything wrong? :(

Originally posted by Afrow UK
Theres a plugin example called ExDll included with the latest NSIS bundle (or source code bundle).
I found it! But I can't understand right now. :eek: In fact I have very poor experience about win32 programming. I'll try to understand it. Thanks!!

Dude!

Your are using C++ and there's a few words to put in each function to be exported:


extern "C" void test(...) 


I found somthing's wrong, but I can't find the solution
  When I compile my nsi file, the log message is quite different from what other usual dll file is included.

This is right log.
- System::Alloc
- System::Call
- System::Copy
- System::Free
- System::Get
- System::Int64Op
- System::Store

And this is unrecognizing message-when mydll is included.
- MyDll::??0CMyDll@@QAE@XZ
- MyDll::??4CMyDll@@QAEAAV0@ABV0@@Z
- MyDll::?nMyDll@@3HA
- MyDll::?test@CMyDll@@QAEHHH@Z


well....I'll try to find the solution. However if you give me some advice or the answer, I'll really appreciate your help. :)


See my last post, you read it, right?


Originally posted by Joel
See my last post, you read it, right?
Ah....I see. I forgot to add 'extern "C"' in front of function and did it only class. ;; My function is working!

I really thank your help!

By the way I have 1 more question. Can't I use class methods? If I add 'extern "C"' in front of member method, log message is still understandable.

extern "C" int CMyDll::test(int x, int y)
{
return x+y;
}

I don't know...maybe...you'll have to try it :)
And if you gonna try it, don't forget to see 4.11.2 Disabling Plug-in Unloading and 4.8.2.9 SetPluginUnload


you can probably export a static class function, but not a normal class method, there would be no this pointer, nsis plugin exports are cdecl and not thiscall