Old 22nd October 2007, 09:21   #1
zepitou
Junior Member
 
Join Date: May 2006
Location: France
Posts: 13
Unable to correctly call a dll using system.dll

Hello,

During my installation flow, I need to check if a cd-key entered by end-user is valid (cd-key is get by a custom page into an ini file). I do it by using a dll.

The dll prototype is:
prototype cdecl BOOL MiscHelper.IsValid(BYVAL STRING, BYREF STRING);

the C prototype is:
typedef DWORD (__cdelc *IsValid) (const char*, const char*);

So the dll name is "MiscHelp.dll" and the exported function to call is "IsValid"

Here is my NSIS code to call the dll (within the main section)

SetOutPath "$PLUGINSDIR"
File "MiscHelper.dll"
ReadINIStr $0 "$PLUGINSDIR\MPkeysRetrieveTest.ini" "Field 1" "State"
StrCpy $1 "timeshift"
System::call "MiscHelper::IsValid(*t, *t) i(r1, r0).r8 ?e"

$1 is a seed name
$0 stores the key to check (and work)

My issue is that the return ($8) is always "0", whatsoever the key is valid or not. If I choose "b" or "t" for return type, I got no return at all.
Notice I've tested the dll with an Installshield script and it does work... but I really need to use NSIS and not IS.
zepitou is offline   Reply With Quote
Old 22nd October 2007, 14:45   #2
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
What happens if you don't use pointers (t instead of *t)?
Also what is the error code that you get? (Pop it to, say, $9)
code:
...
System::call "MiscHelper::IsValid(t r1, t r2)i.r8 ?e"
Pop $9
...


CF
CancerFace is offline   Reply With Quote
Old 23rd October 2007, 01:01   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
First of all, if it's cdecl, you need to tell System. The default is stdcall. Use ?c.

Next is what CancerFace said. It's not a pointer to a string, it's a string.

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 24th October 2007, 13:32   #4
zepitou
Junior Member
 
Join Date: May 2006
Location: France
Posts: 13
Well!

Many thanks for your answers as it solved my issue!

Best regards to both of you!
zepitou
zepitou 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