PDA

View Full Version : Call Function from DLL witch returns True or False


marcel-slip
26th February 2009, 08:36
Hello,

I have a library. Dll file that has the function of checking the key in the registry. Library returns the value true or false. Can this somehow be supported by NSIS?
Here is an code with InstallShield:


prototype BOOL werk.werk();
prototype NUMBER werk.WriteToReg(POINTER, POINTER, POINTER);
prototype NUMBER werk.CreateRegKey();

function BOOL VerifySerial()
STRING szFileName;
  NUMBER nResult;
  BOOL bVerified;
begin 
  szFileName = SUPPORTDIR ^ "some.dll";

  nResult = UseDLL(szFileName);
  if (nResult=0) then
   bVerified = some.some();
  else         
   bVerified = FALSE;
   MessageBox(@MSG_DLLERROR, INFORMATION);
  endif;
  nResult = UnUseDLL(szFileName);
 
  return bVerified;
end;

Afrow UK
26th February 2009, 10:12
Call it with the System plug-in.

Edit: Or convert it to an NSIS plug-in.
Or write the code in NSIS.

Stu

marcel-slip
26th February 2009, 11:01
Thank you for your reply.
I don't know how to do this. I do not have access to the source libraries and at the worst I have enough time to perform;)
Any example?

Afrow UK
26th February 2009, 11:11
There are many many examples of the 3 options I have outlined. You will find them here, on the Wiki and with your NSIS installation.

Stu

marcel-slip
27th February 2009, 08:07
Hello


I'm not as good with nsis-a. I tried to do is this:


Function some
SetOutPath c:\temp
File test.dll
System::Call 'test.dll::work() b(r0)'
DetailPrint 'Path: "$0"'
Dumpstate::debug ;test variable
FunctionEnd




I do not see any effect, the variable 0 has no value assigned

Anders
27th February 2009, 08:18
there is no such thing as b, you need to read the system plugin readme, you can't just make up types!

the windows BOOL type is 4 bytes, use i
the c++ bool type is 1 byte

marcel-slip
27th February 2009, 09:22
Thank you very much for your help.
The following function works:

Function werk
SetOutPath c:\temp
File test.dll
System::Call 'test.dll::work() i() .r3'
FunctionEnd


The $3 is the state of 0-folse or 1-true