Old 28th May 2010, 09:53   #1
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
how to use library WinSCard with NSIS

hello,
I try to use this function:

lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
NULL,
NULL,
phSC);

with NSIS!

i try:

!define SCardListReaders "Advapi32::SCardListReaders(l,t,*t,*l) i"

System::Call "${SCardEstablishContext}(${SCARD_SCOPE_USER},0, 0, .r0) .r1"


It's not work! CAn you help me, please??
maanifiik is offline   Reply With Quote
Old 28th May 2010, 10:33   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Quote:
Originally Posted by maanifiik View Post
!define SCardListReaders "Advapi32::SCardListReaders(l,t,*t,*l) i"
System::Call "${SCardEstablishContext}(${SCARD_SCOPE_USER},0, 0, .r0) .r1"
You're defining it as SCardListReaders, but then calling another define (SCardEstablishContext).
MSG is offline   Reply With Quote
Old 28th May 2010, 11:51   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Also * isn't used for pointers. Just use i or l.

Stu
Afrow UK is offline   Reply With Quote
Old 28th May 2010, 11:59   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
MSDN says these functions are in Winscard, not Advapi32.
You also can't just use random windows constants/defines, you need to !define them because nsis does not mirror the entire windows sdk!

Maybe something like:
code:

!define SCARD_SCOPE_USER 0
!define SCARD_AUTOALLOCATE -1
!define SCARD_S_SUCCESS 0

!include LogicLib.nsh

System::Call 'Winscard::SCardEstablishContext(i ${SCARD_SCOPE_USER},i0,i0,*i.r1)i.r0'
${If} $0 = ${SCARD_S_SUCCESS}
System::Call 'Winscard::SCardListReaders(ir1,i0,*i.r2,*i ${SCARD_AUTOALLOCATE})i.r0'
${If} $0 = ${SCARD_S_SUCCESS} ;might also want to check for SCARD_E_NO_READERS_AVAILABLE?
;do something with $2 ("multi-string")
System::Call 'Winscard::SCardFreeMemory(ir1,ir2)'
${EndIf}
System::Call 'Winscard::SCardReleaseContext(ir1)'
${EndIf}



Note: I have never used the Winscard API and I'm coding this in the forum reply box without testing so there are probably bugs!

Afrow:* are for pointers, but t is a pointer already on the "winapi side" of system.dll

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th May 2010, 12:47   #5
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
thanks for your answer!

I'm going to test this code!
maanifiik is offline   Reply With Quote
Old 28th May 2010, 13:51   #6
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
IT'S WORK!

I love you!

Thanks YOU
maanifiik is offline   Reply With Quote
Old 28th May 2010, 15:13   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thanks Anders. I'm a little confused with p now. Is that for handles (HANDLE, PVOID etc)? For example, in the System readme under Copy -> Usage example, p has been used for returning a pointer to the allocated buffer "allocate a buffer and put 'test string' and an int in it". I think that's a typo? Shouldn't it be i? p certainly doesn't work when I try it...

Stu
Afrow UK is offline   Reply With Quote
Old 28th May 2010, 18:50   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
Afrow: p is only a valid type in "2.47" (eg SVN only at this point) (Why the online docs are the svn version and not just the latest stable version, I don't know) And yes, they are for pointers like handle/void* etc

As far as * goes, if you had a C function like: void foo(HANDLE p1,HANDLE*p2) the system syntax would be System::Call foodll::foo(p [???],*p [???|.][???]) Ex: System::Call foodll::foo(p $somehandlevalue,*p.r2) ... (p2 input: function foo gets a pointer to a pointer-sized memory location with undefined contents. p2 output: lets say foo() did: *p2=p1->somevalue;, after the call returns, $2 contains the same value as p1->somevalue)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 28th May 2010, 19:17   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Ah that explains all. Thanks again.

Stu
Afrow UK is offline   Reply With Quote
Old 31st May 2010, 15:22   #10
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
Hey guys,,

I have 2 questions:

Firstly, I want to cut a string, for example :

"C:\Mes documents\hahaha.txt" => "hahaha.txt"

Secondly, I don't want to have a lot of directory with my NSIS.exe! I want to have one file only .
With my exe, i have 2 directory. for example, in one directory , i have the exe of java! It's possible to do that?????
maanifiik is offline   Reply With Quote
Old 31st May 2010, 16:02   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
1. http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.16
2. Have you had a look at the examples? http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.5

Stu
Afrow UK is offline   Reply With Quote
Old 3rd June 2010, 09:41   #12
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
Hey,

I have a new question! I have a .ini file! I want to configure the .ini after execute my setup but he have to do a new compilation.
Is it possible to modify the .ini file after the compilation???????
maanifiik is offline   Reply With Quote
Old 3rd June 2010, 10:02   #13
maanifiik
Junior Member
 
Join Date: May 2010
Posts: 6
Sorry, i have the answer.

I don't give the true path
maanifiik 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