PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD] Converting source from C# to WLanguage
[WD] Converting source from C# to WLanguage
Iniciado por guest, 01,mar. 2018 22:02 - 2 respuestas
Publicado el 01,marzo 2018 - 22:02
Hello to all

I'm trying to convert this little piece of code from C# to Windev wlanguage.

using System; using System.Collections.Generic; using System.Text; using Cryptware.NSCAPI; using Cryptware.NCNSAPI; using System.Security.Cryptography.X509Certificates; namespace TestNCNSAPI { class Program { static void Main(string[] args) { SmartCardManager scman = new SmartCardManager(); Readers readerList = scman.PluggedReaders; Reader reader = readerList[0]; Console.WriteLine(reader.Name); Console.WriteLine(reader.State); Console.WriteLine(reader.IsSmartCardPresent); int nRes = reader.WaitForSmartCardInserted(Reader.INFINITE); SmartCard card = reader.Connect(); CNS cns = new CNS(card); string[] datiPersonali = cns.ReadDatiPersonali(); Console.WriteLine("Nome: " + datiPersonali[CNS.Nome]); Console.WriteLine("Cognnome: " + datiPersonali[CNS.Cognome]); X509Certificate2 cert = cns.ReadCertificatoX509(); Console.WriteLine("Scadenza certificato: " + cert.GetExpirationDateString()); } } }
Please, can someone help me in this translation ???

Thanks in advance.
Gianni
Publicado el 02,marzo 2018 - 00:01
Hello Fabrice

Thank you.

Gianni
Publicado el 02,marzo 2018 - 11:24
Hi Gianni,

these lines:
using System;
using System.Collections.Generic;
using System.Text;
using Cryptware.NSCAPI;
using Cryptware.NCNSAPI;
using System.Security.Cryptography.X509Certificates;

are the list of .net assemblies you need to import in your project...

Once it's done, you can create a procedure in which you paste this:
SmartCardManager scman = new SmartCardManager();

Readers readerList = scman.PluggedReaders;

Reader reader = readerList[0];

Console.WriteLine(reader.Name);
Console.WriteLine(reader.State);
Console.WriteLine(reader.IsSmartCardPresent);

int nRes = reader.WaitForSmartCardInserted(Reader.INFINITE);

SmartCard card = reader.Connect();

CNS cns = new CNS(card);

string[] datiPersonali = cns.ReadDatiPersonali();
Console.WriteLine("Nome: " + datiPersonali[CNS.Nome]);
Console.WriteLine("Cognnome: " + datiPersonali[CNS.Cognome]);

X509Certificate2 cert = cns.ReadCertificatoX509();
Console.WriteLine("Scadenza certificato: " + cert.GetExpirationDateString());

and you can start correcting errors line after line... There is a help page describing converions from C AND you can also use wdapi to convert a piece of C.

Once you've done all that, you can come back here for help on a precise problem.

Best regards