Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling a DLL function that returns a struct in NSIS.

Posted on 2010-09-24
6
Medium Priority
?
1,231 Views
Last Modified: 2012-05-11
Hi experts I have created an NSIS installer that is now required to check the version of a DLL before it installs the file. The DLL is written in C and the function I am trying to call is the following:

EXPORT int __stdcall getVersion(VERSION_STRUCT* version){
      
            version->major = verMajor;
            version->minor = verMinor;
            version->revision = verRevision;
            
            return 1;
}            

My question is how can you create a struct in the .nsi script, assign values to this struct by calling the getVersion function in the DLL from the .nsi script,  and finally how can I compare the components of the struct to other integers to check if the DLL is a new version or not.

A VBScript solution is also possible, but not preferred.

Thanks.
0
Comment
Question by:jonathan_hills
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1500 total points
ID: 33755861
Take a look at http://nsis.sourceforge.net/Calling_an_external_DLL_using_the_System.dll_plugin ("Calling an external DLL using the System.dll plugin") - the scoop would be to

System::Call 'YourDllName::YourDllFunction(i, *i, t) i(.r0, r1, .r2) .r3'
0
 

Author Comment

by:jonathan_hills
ID: 33756195
Okay thank-you I will try to make i work and I will get back to you.
0
 

Author Comment

by:jonathan_hills
ID: 33757205
So far I have this in my function in the .nsi script:


SetOutPath $TEMP\eInspect                               ; create temp directory
      file "..\bin\myDLL.dll"            ; copy dll there

       # allocate
      System::Alloc 12

      Pop $0
      System::Call "*$0(i 5, i 2, i 513)"

      # call
      System::Call "..\bin\myDLL.dll::getVersion(i r0)"

      # get       
      System::Call "*$0(i.r0, i.r1, i.r2)"
      
      # print
      DetailPrint "Major: $0"
      DetailPrint "Minor: $1"
      DetailPrint "Revision: $2"
      #free
      System::Free $0

And in my dll function I have

EXPORT int __stdcall getVersion(VERSION_STRUCT* version){
      
            version->major = verMajor;
            version->minor = verMinor;
            version->revision = verRevision;
            
            return 1;
}                  


It runs it is just the numbers contained in the struct do not change from the initial values I give them. What am I doing wrong with the DLL function call?

SetOutPath $TEMP\eInspect             			; create temp directory
	file "..\bin\myDLL.dll"            ; copy dll there

	 # allocate
	System::Alloc 12

	Pop $0
	System::Call "*$0(i 5, i 2, i 513)"

	# call
	System::Call "..\bin\myDLL.dll::getVersion(i r0)"

	# get	 
	System::Call "*$0(i.r0, i.r1, i.r2)"
	
	# print free
	DetailPrint "Major: $0"
	DetailPrint "Minor: $1"
	DetailPrint "Revision: $2"
	#free
	System::Free $0

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:jonathan_hills
ID: 33757212
Sorry duplicate code posted in that post above.
0
 

Author Comment

by:jonathan_hills
ID: 33757343
Never mind I ended up figuring it out, thanks for the help jkr.
0
 

Author Closing Comment

by:jonathan_hills
ID: 33757347
Not a complete answer to the question, but still pointed me in the correct direction.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question