Old 27th December 2002, 12:11   #1
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
Question How to make DLL Plugins

Hello All,

I'm using NSIS for creating a setup.

After reading the documents, I'm still not clear how to
call any function in dll from .nsi file.

If anybody having example of DLL Plugin please do mail me
at ppp_pras@yahoo.com
prasanna is offline   Reply With Quote
Old 27th December 2002, 12:41   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Put your DLL in the Plugins directory or call PluginDir with the directory in which this plugin resides and then use DllNameWithOut.DllExtension::FunctionName.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th December 2002, 12:56   #3
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
Question Further Problem : kichik

Hello kichik,

Your reply helped me a lot.

But now I am not getting how to pass the Arguments to the function.
and get return datatypes.

Please help me.
prasanna is offline   Reply With Quote
Old 27th December 2002, 13:07   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Passing and getting parameters to and from the plug-in can be done in two ways. The first is using the NSIS stack (push and pop) the second is through the NSIS variables. You can access both from the plug-in using pushstring, popstring, getuservariable and setuservariable (all defined in ExDLL.h in Contrib\ExDLL).

The preferred way is using the NSIS stack. To pass arguments to the plug-in use:

PluginName::Function arg1 arg2 arg3

The arguments will be pushed to the stack from right to left. The first time you call popstring in the plug-in you will get arg3 (you can push as many arguments as you want as long as there is enough memory ).

To get the "return value" of the plug-in (preferably strings pushed by the plug-in) use Pop in NSIS:

PluginName::Function arg1 arg2 arg3
Pop $0

The only data type NSIS knows is a string. If you want to convert the strings NSIS pushes on the stack you will have to use your own functions. You can find some in the other plug-ins written.

Please reply to this thread next time instead of opening another one.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 28th December 2002, 10:30   #5
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
Hi All,

Kichik you told me how to call any function from pluginn dll.

See I'm trying to execute following code.
After Testing Installation. It give error and says "error log is being written"

1) Where is the error log?

I'm trying to execute following code

StrCpy $R1 "LFcl"
StrCpy $R2 "CeloxisCond"
StrCpy $R3 "C:\\CDK402a\\Common\\Bin\\C4.02\\jsync13.dll"
CondMgr::CmInstallCreator $R1 "1"
CondMgr::CmSetCreatorName $R1 $R3
CondMgr::CmSetCreatorDirectory $R1 $R2
CondMgr::CmSetCreatorFile $R1 $R2
CondMgr::CmSetCreatorPriority $R1 "1"

But it's not working

Please help me in this regards.
prasanna is offline   Reply With Quote
Old 28th December 2002, 11:08   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
NSIS has no such error message ("error log is being written"). Are you sure it comes from NSIS and not your plug-in? Are you sure you copied it right?
Escaping the back-slashes in $R3 which is not needed in NSIS. I don't see anything wrong in this piece of code but that.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 28th December 2002, 13:00   #7
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
StrCpy $R1 "LFcl"
CondMgr::CmInstallCreator $R1 1

I can Compile NSIS script containing above lines. So there is no doubt that the file is there or not. Now when I click on Test Installer it runs my Executable(Installer). And at the point where I called that function it gives error
as follows:
-------------------------------------
Installer.exe has generated errors and will be closed by Windows. You will need to restart the program.

An error log is being created.

------------------------------------
Please guide me how to debug the error in such situation.
prasanna is offline   Reply With Quote
Old 28th December 2002, 13:09   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
If the error occurs when you call your plug-in the problem is in your plug-in. To make sure put a message box before and after the call to the plug-in. If the first one shows but the second doesn't it's your plug-in for sure. To debug your plug-in compile it in debug mode and debug... As I don't have the plug-in source I can't help you much there...

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th December 2002, 07:49   #9
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
HsCheckApiStatus prototype is :
long WINAPI HsCheckApiStatus (void);

HSAPI::HsCheckApiStatus
Pop $0
IntCmp $0 HSAPI::ERROR_HSAPI_HOTSYNC_NOT_FOUND hotsync_not_running
IntCmp $0 HSAPI::ERROR_HSAPI_FAILURE hotsync_api_failure

MessageBox MB_OK "HOT SYNC.$0"
return

hotsync_not_running:
MessageBox MB_OK "HOT SYNC NOT RUNNING. PLEASE START HOTSYNC."
return
hotsync_api_failure:
MessageBox MB_OK "HOT SYNC API FAILURE"
return
-----------------------------------------------------------
This is my api and this is how I have written code.
Problem is it always goes to label
"HOT SYNC NOT RUNNING. PLEASE START HOTSYNC."

How to deal with return types that are long or int?
prasanna is offline   Reply With Quote
Old 30th December 2002, 09:33   #10
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
I'm writting a code in NSIS which deals with DLL plugins.
The function has two arguments: the first one is an integer and the second is a char *.
How does one pass Integer and String to that function?

The function which I call returns an integer.
How to get this integer value in variable? Pop documentation says it pops of a string.

Can I use the return value (after getting it as described above) in IntCmp?
prasanna is offline   Reply With Quote
Old 30th December 2002, 14:38   #11
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
The prototype you used is wrong. The right prototype as mentioned in the ExDLL example is:
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size, char *variables, stack_t **stacktop);

Data types:

Quote:
The only data type NSIS knows is a string. If you want to convert the strings NSIS pushes on the stack you will have to use your own functions. You can find some in the other plug-ins written.
Same goes for what NSIS accepts... The only data type NSIS knows is strings which means you will have to convert your output to a string and push it on the stack.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 31st December 2002, 05:41   #12
prasanna
Junior Member
 
Join Date: Dec 2002
Location: India
Posts: 7
Send a message via Yahoo to prasanna
Hello kichik,

Do you know which DLLs provide such fuctions. Please give me names of such DLL files.
prasanna is offline   Reply With Quote
Old 31st December 2002, 13:46   #13
Sunjammer
Major Dude
 
Join Date: Jun 2002
Location: Swindon, UK
Posts: 559
- contrib/nsexec.c uses wsprintf to convert ints to strings
- contrib/nsexec.c implements my_atoi to convert strings to ints
- contrib/advsplash.c uses wsprintf to convert ints to strings
- contrib/advsplash.c implements myatoi to convert strings to ints
- contrib/langdll.c implements myatoi to convert strings to ints
- contrib/nsisdl/util.cpp implements my_atoi to convert strings to ints (and also implements mini_memset and mini_memcpy)
- contrib/splash.c converts strings to ints using inline code (line 70)
- contrib/splash.c converts ints to strings using wsprintf
- contrib/system/source/plugin.c implements myitao, myitoa64, popint, pushint and copymem

That should give you some idea what KiCHiK was on about.
Sunjammer is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump