Archive: how to use library WinSCard with NSIS


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??


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).

Also * isn't used for pointers. Just use i or l.

Stu


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

thanks for your answer!

I'm going to test this code!


IT'S WORK!

I love you!

Thanks YOU


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: 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)


Ah that explains all. Thanks again.

Stu


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?????


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


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???????


Sorry, i have the answer.

I don't give the true path