- NSIS Discussion
- how to use library WinSCard with NSIS
Archive: how to use library WinSCard with NSIS
maanifiik
28th May 2010 10:53 UTC
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??
MSG
28th May 2010 11:33 UTC
Originally posted by maanifiik
!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).
Afrow UK
28th May 2010 12:51 UTC
Also * isn't used for pointers. Just use i or l.
Stu
Anders
28th May 2010 12:59 UTC
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:
!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
maanifiik
28th May 2010 13:47 UTC
thanks for your answer!
I'm going to test this code!
maanifiik
28th May 2010 14:51 UTC
IT'S WORK!
I love you!
Thanks YOU
Afrow UK
28th May 2010 16:13 UTC
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
Anders
28th May 2010 19:50 UTC
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)
Afrow UK
28th May 2010 20:17 UTC
Ah that explains all. Thanks again.
Stu
maanifiik
31st May 2010 16:22 UTC
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
3rd June 2010 10:41 UTC
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
3rd June 2010 11:02 UTC
Sorry, i have the answer.
I don't give the true path