|
(SQL Server) Gather Smartcard Debug Information for Chilkat
This example demonstrates how to gather information to send to support@chilkatsoft.com about your smartcard.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
-- First, Chilkat recommends downloading the MGTEK Smartcard Minidriver Tool to get information
-- about your smartcard.
-- The tool can be downloaded from https://www.mgtek.com/smartcard
-- --------------------------------------------------------------------------------------------------------
-- 1. Select the smartcard as shown below and send Chilkat a screenshot of the basic smartcard information.
-- --------------------------------------------------------------------------------------------------------
--
--
-- --------------------------------------------------------------------------------------------------------
-- 2. Select the cmapfile (if present) as shown below and send Chilkat a screenshot of the CSP container map
-- --------------------------------------------------------------------------------------------------------
--
--
-- ---------------------------------------------------------
-- Chilkat provides functions to get information about the smartcard, and what it contains.
-- Send Chilkat the output of the following source code:
DECLARE @scmd int
-- Use "Chilkat_9_5_0.ScMinidriver" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.ScMinidriver', @scmd OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Reader names (smart card readers or USB tokens) can be discovered
-- via PCSC List Readers or PCSC Find Smart Cards
DECLARE @readerName nvarchar(4000)
SELECT @readerName = 'Alcor Micro USB Smart Card Reader 0'
DECLARE @success int
EXEC sp_OAMethod @scmd, 'AcquireContext', @success OUT, @readerName
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @scmd
RETURN
END
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OASetProperty @json, 'EmitCompact', 0
-- ------------------------------------------------------
-- 3. Send Chilkat the JSON returned by GetCardProperties
-- ------------------------------------------------------
EXEC sp_OAMethod @scmd, 'GetCardProperties', @success OUT, @json
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @scmd
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
PRINT @sTmp0
-- ------------------------------------------------------
-- 4. Send Chilkat the JSON returned by GetCspContainerMap
-- ------------------------------------------------------
EXEC sp_OAMethod @json, 'Clear', NULL
EXEC sp_OAMethod @scmd, 'GetCspContainerMap', @success OUT, @json
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @scmd, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @scmd
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @scmd
EXEC @hr = sp_OADestroy @json
END
GO
|